1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2006 - Stefan Kueng
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.
26 IMPLEMENT_DYNAMIC(CFindDlg
, CResizableStandAloneDialog
)
28 CFindDlg::CFindDlg(CWnd
* pParent
/*=NULL*/)
29 : CResizableStandAloneDialog(CFindDlg::IDD
, pParent
)
30 , m_bTerminating(false)
33 , m_bLimitToDiffs(FALSE
)
44 void CFindDlg::DoDataExchange(CDataExchange
* pDX
)
46 CDialog::DoDataExchange(pDX
);
47 DDX_Check(pDX
, IDC_MATCHCASE
, m_bMatchCase
);
48 DDX_Check(pDX
, IDC_WHOLEWORD
, m_bWholeWord
);
49 DDX_Control(pDX
, IDC_FINDCOMBO
, m_FindCombo
);
50 DDX_Control(pDX
, IDC_LIST_REF
, m_ctrlRefList
);
51 DDX_Control(pDX
, IDC_EDIT_FILTER
, m_ctrlFilter
);
55 BEGIN_MESSAGE_MAP(CFindDlg
, CResizableStandAloneDialog
)
56 ON_CBN_EDITCHANGE(IDC_FINDCOMBO
, &CFindDlg::OnCbnEditchangeFindcombo
)
57 ON_NOTIFY(NM_CLICK
, IDC_LIST_REF
, &CFindDlg::OnNMClickListRef
)
58 ON_EN_CHANGE(IDC_EDIT_FILTER
, &CFindDlg::OnEnChangeEditFilter
)
63 // CFindDlg message handlers
65 void CFindDlg::OnCancel()
67 m_bTerminating
= true;
69 CWnd
*parent
= m_pParent
;
74 parent
->SendMessage(m_FindMsg
);
79 void CFindDlg::PostNcDestroy()
87 m_FindCombo
.SaveHistory();
89 if (m_FindCombo
.GetString().IsEmpty())
92 m_FindString
= m_FindCombo
.GetString();
94 CWnd
*parent
= m_pParent
;
99 parent
->SendMessage(m_FindMsg
);
103 BOOL
CFindDlg::OnInitDialog()
105 CDialog::OnInitDialog();
106 m_FindMsg
= RegisterWindowMessage(FINDMSGSTRING
);
108 m_FindCombo
.LoadHistory(_T("Software\\TortoiseGit\\History\\Find"), _T("Search"));
110 m_FindCombo
.SetFocus();
112 this->AddAnchor(IDC_STATIC_FIND
, TOP_LEFT
, TOP_RIGHT
);
113 this->AddAnchor(IDC_FINDCOMBO
, TOP_LEFT
, TOP_RIGHT
);
114 this->AddAnchor(IDOK
, TOP_RIGHT
);
115 this->AddAnchor(IDCANCEL
, TOP_RIGHT
);
116 this->AddAnchor(IDC_STATIC_GROUP_REF
, TOP_LEFT
, BOTTOM_RIGHT
);
117 this->AddAnchor(IDC_STATIC_FILTER
, BOTTOM_LEFT
);
118 this->AddAnchor(IDC_EDIT_FILTER
, BOTTOM_LEFT
, BOTTOM_RIGHT
);
119 this->AddAnchor(IDC_LIST_REF
, TOP_LEFT
, BOTTOM_RIGHT
);
120 this->AddOthersToAnchor();
122 EnableSaveRestore(_T("FindDlg"));
124 CImageList
*imagelist
= new CImageList();
125 imagelist
->Create(IDB_BITMAP_REFTYPE
,16,3,RGB(255,255,255));
126 this->m_ctrlRefList
.SetImageList(imagelist
,LVSIL_SMALL
);
129 m_ctrlRefList
.GetClientRect(&rect
);
131 this->m_ctrlRefList
.InsertColumn(0,_T("Ref"),0, rect
.Width()-50);
132 g_Git
.GetRefList(m_RefList
);
137 void CFindDlg::OnCbnEditchangeFindcombo()
140 GetDlgItem(IDOK
)->EnableWindow(!m_FindCombo
.GetString().IsEmpty());
143 void CFindDlg::AddToList()
145 this->m_ctrlRefList
.DeleteAllItems();
147 this->m_ctrlFilter
.GetWindowText(filter
);
150 for(int i
=0;i
< m_RefList
.size();i
++)
153 CString ref
= m_RefList
[i
];
154 if(ref
.Find(_T("refs/tags")) == 0)
156 else if(ref
.Find(_T("refs/remotes"))==0)
158 else if(ref
.Find(_T("refs/heads"))== 0)
161 if(ref
.Find(filter
)>=0)
162 m_ctrlRefList
.InsertItem(item
++,ref
,nImage
);
166 void CFindDlg::OnNMClickListRef(NMHDR
*pNMHDR
, LRESULT
*pResult
)
168 LPNMITEMACTIVATE pNMItemActivate
= reinterpret_cast<LPNMITEMACTIVATE
>(pNMHDR
);
170 this->m_FindString
= this->m_ctrlRefList
.GetItemText(pNMItemActivate
->iItem
,0);
171 this->m_bIsRef
=true;
173 CWnd
*parent
= m_pParent
;
175 parent
= GetParent();
178 parent
->SendMessage(m_FindMsg
);
180 this->m_bIsRef
=false;
185 void CFindDlg::OnEnChangeEditFilter()
187 SetTimer(IDT_FILTER
, 1000, NULL
);
190 void CFindDlg::OnTimer(UINT_PTR nIDEvent
)
192 if( nIDEvent
== IDT_FILTER
)
194 KillTimer(IDT_FILTER
);
198 CResizableStandAloneDialog::OnTimer(nIDEvent
);