OSDN Git Service

Add Help button handle and add Anchor at format patch for refbrowse button
[tortoisegit/TortoiseGitJp.git] / src / TortoiseProc / FormatPatchDlg.cpp
1 // FormatPatch.cpp : implementation file\r
2 //\r
3 \r
4 #include "stdafx.h"\r
5 #include "TortoiseProc.h"\r
6 #include "FormatPatchDlg.h"\r
7 #include "git.h"\r
8 #include "BrowseFolder.h"\r
9 #include "LogDlg.h"\r
10 #include "BrowseRefsDlg.h"\r
11 // CFormatPatchDlg dialog\r
12 \r
13 IMPLEMENT_DYNAMIC(CFormatPatchDlg, CResizableStandAloneDialog)\r
14 \r
15 CFormatPatchDlg::CFormatPatchDlg(CWnd* pParent /*=NULL*/)\r
16         : CResizableStandAloneDialog(CFormatPatchDlg::IDD, pParent),\r
17         m_regSendMail(_T("Software\\TortoiseGit\\TortoiseProc\\FormatPatch\\SendMail"),0)\r
18 {\r
19         m_Num=1;\r
20         this->m_bSendMail = m_regSendMail;\r
21         this->m_Radio = IDC_RADIO_SINCE;\r
22 }\r
23 \r
24 CFormatPatchDlg::~CFormatPatchDlg()\r
25 {\r
26 }\r
27 \r
28 void CFormatPatchDlg::DoDataExchange(CDataExchange* pDX)\r
29 {\r
30         CDialog::DoDataExchange(pDX);\r
31         DDX_Control(pDX, IDC_COMBOBOXEX_DIR,    m_cDir);\r
32         DDX_Control(pDX, IDC_COMBOBOXEX_SINCE,  m_cSince);\r
33         DDX_Control(pDX, IDC_COMBOBOXEX_FROM,   m_cFrom);\r
34         DDX_Control(pDX, IDC_COMBOBOXEX_TO,             m_cTo);\r
35         DDX_Control(pDX, IDC_EDIT_NUM,                  m_cNum);\r
36 \r
37         DDX_Text(pDX,IDC_EDIT_NUM,m_Num);\r
38 \r
39         DDX_Text(pDX, IDC_COMBOBOXEX_DIR,       m_Dir);\r
40         DDX_Text(pDX, IDC_COMBOBOXEX_SINCE,     m_Since);\r
41         DDX_Text(pDX, IDC_COMBOBOXEX_FROM,      m_From);\r
42         DDX_Text(pDX, IDC_COMBOBOXEX_TO,        m_To);\r
43         \r
44         DDX_Check(pDX, IDC_CHECK_SENDMAIL, m_bSendMail);\r
45 }\r
46 \r
47 \r
48 BEGIN_MESSAGE_MAP(CFormatPatchDlg, CResizableStandAloneDialog)\r
49         ON_BN_CLICKED(IDC_BUTTON_DIR, &CFormatPatchDlg::OnBnClickedButtonDir)\r
50         ON_BN_CLICKED(IDC_BUTTON_FROM, &CFormatPatchDlg::OnBnClickedButtonFrom)\r
51         ON_BN_CLICKED(IDC_BUTTON_TO, &CFormatPatchDlg::OnBnClickedButtonTo)\r
52         ON_BN_CLICKED(IDOK, &CFormatPatchDlg::OnBnClickedOk)\r
53         ON_BN_CLICKED(IDC_RADIO_SINCE, &CFormatPatchDlg::OnBnClickedRadio)\r
54         ON_BN_CLICKED(IDC_RADIO_NUM, &CFormatPatchDlg::OnBnClickedRadio)\r
55         ON_BN_CLICKED(IDC_RADIO_RANGE, &CFormatPatchDlg::OnBnClickedRadio)\r
56         ON_BN_CLICKED(IDC_BUTTON_REF, &CFormatPatchDlg::OnBnClickedButtonRef)\r
57 END_MESSAGE_MAP()\r
58 \r
59 BOOL CFormatPatchDlg::OnInitDialog()\r
60 {\r
61         CResizableStandAloneDialog::OnInitDialog();\r
62         \r
63         AddAnchor(IDC_GROUP_DIR, TOP_LEFT, TOP_RIGHT);\r
64         AddAnchor(IDC_COMBOBOXEX_DIR,TOP_LEFT, TOP_RIGHT);\r
65         AddAnchor(IDC_BUTTON_DIR, TOP_RIGHT);\r
66 \r
67         AddAnchor(IDC_GROUP_VERSION, TOP_LEFT, TOP_RIGHT);\r
68         AddAnchor(IDC_COMBOBOXEX_SINCE, TOP_LEFT, TOP_RIGHT);\r
69         AddAnchor(IDC_EDIT_NUM, TOP_LEFT, TOP_RIGHT);\r
70         AddAnchor(IDC_SPIN_NUM, TOP_RIGHT);\r
71 \r
72         AddAnchor(IDC_COMBOBOXEX_FROM, TOP_LEFT, TOP_RIGHT);\r
73         AddAnchor(IDC_COMBOBOXEX_TO, TOP_LEFT, TOP_RIGHT);\r
74 \r
75         AddAnchor(IDC_BUTTON_FROM,  TOP_RIGHT);\r
76         AddAnchor(IDC_BUTTON_TO,        TOP_RIGHT);\r
77         AddAnchor(IDC_CHECK_SENDMAIL,BOTTOM_LEFT);\r
78         AddAnchor(IDOK,BOTTOM_RIGHT);\r
79         AddAnchor(IDCANCEL,BOTTOM_RIGHT);\r
80         AddAnchor(IDHELP, BOTTOM_RIGHT);\r
81         AddAnchor(IDC_BUTTON_REF,TOP_RIGHT);\r
82 \r
83         this->AddOthersToAnchor();\r
84 \r
85         m_cDir.SetPathHistory(TRUE);\r
86         m_cDir.LoadHistory(_T("Software\\TortoiseGit\\History\\FormatPatchURLS"), _T("path"));\r
87         m_cDir.SetCurSel(0);\r
88 \r
89         STRING_VECTOR list;\r
90         g_Git.GetBranchList(list,NULL,CGit::BRANCH_ALL);\r
91         m_cSince.SetMaxHistoryItems(list.size());\r
92         m_cSince.AddString(list);\r
93 \r
94         if(!m_Since.IsEmpty())\r
95                 m_cSince.SetWindowText(m_Since);\r
96 \r
97         m_cFrom.LoadHistory(_T("Software\\TortoiseGit\\History\\FormatPatchFromURLS"), _T("ver"));\r
98         m_cFrom.SetCurSel(0);\r
99 \r
100         if(!m_From.IsEmpty())\r
101                 m_cFrom.SetWindowText(m_From);\r
102 \r
103         m_cTo.LoadHistory(_T("Software\\TortoiseGit\\History\\FormatPatchToURLS"), _T("ver"));\r
104         m_cTo.SetCurSel(0);\r
105 \r
106         if(!m_To.IsEmpty())\r
107                 m_cTo.SetWindowText(m_To);\r
108 \r
109         this->CheckRadioButton(IDC_RADIO_SINCE,IDC_RADIO_RANGE,this->m_Radio);\r
110         \r
111         OnBnClickedRadio();\r
112 \r
113         EnableSaveRestore(_T("FormatPatchDlg"));\r
114         return TRUE;\r
115 }\r
116 // CFormatPatchDlg message handlers\r
117 \r
118 void CFormatPatchDlg::OnBnClickedButtonDir()\r
119 {\r
120         // TODO: Add your control notification handler code here\r
121         CBrowseFolder browseFolder;\r
122         browseFolder.m_style = BIF_EDITBOX | BIF_NEWDIALOGSTYLE | BIF_RETURNFSANCESTORS | BIF_RETURNONLYFSDIRS;\r
123         CString strCloneDirectory;\r
124         this->UpdateData(TRUE);\r
125         strCloneDirectory=m_Dir;\r
126         if (browseFolder.Show(GetSafeHwnd(), strCloneDirectory) == CBrowseFolder::OK) \r
127         {\r
128                 m_Dir=strCloneDirectory;\r
129                 this->UpdateData(FALSE);\r
130         }\r
131 }\r
132 \r
133 void CFormatPatchDlg::OnBnClickedButtonFrom()\r
134 {\r
135         CLogDlg dlg;\r
136         // tell the dialog to use mode for selecting revisions\r
137         dlg.SetSelect(true);\r
138         // only one revision must be selected however\r
139         dlg.SingleSelection(true);\r
140         if ( dlg.DoModal() == IDOK )\r
141         {\r
142                 // get selected hash if any\r
143                 CString selectedHash = dlg.GetSelectedHash();\r
144                 // load into window, do this even if empty so that it is clear that nothing has been selected\r
145                 m_cFrom.AddString(selectedHash);\r
146                 CheckRadioButton(IDC_RADIO_SINCE, IDC_RADIO_RANGE, IDC_RADIO_RANGE);\r
147                 OnBnClickedRadio();\r
148         }\r
149 }\r
150 \r
151 void CFormatPatchDlg::OnBnClickedButtonTo()\r
152 {\r
153         CLogDlg dlg;\r
154         // tell the dialog to use mode for selecting revisions\r
155         dlg.SetSelect(true);\r
156         // only one revision must be selected however\r
157         dlg.SingleSelection(true);\r
158         if ( dlg.DoModal() == IDOK )\r
159         {\r
160                 // get selected hash if any\r
161                 CString selectedHash = dlg.GetSelectedHash();\r
162                 // load into window, do this even if empty so that it is clear that nothing has been selected\r
163                 m_cTo.AddString(selectedHash);\r
164                 CheckRadioButton(IDC_RADIO_SINCE, IDC_RADIO_RANGE, IDC_RADIO_RANGE);\r
165                 OnBnClickedRadio();\r
166         }\r
167 }\r
168 \r
169 void CFormatPatchDlg::OnBnClickedOk()\r
170 {\r
171         // TODO: Add your control notification handler code here\r
172 \r
173         m_cDir.SaveHistory();\r
174         m_cFrom.SaveHistory();\r
175         m_cTo.SaveHistory();\r
176         this->UpdateData(TRUE);\r
177         this->m_Radio=GetCheckedRadioButton(IDC_RADIO_SINCE,IDC_RADIO_RANGE);\r
178 \r
179         m_regSendMail=this->m_bSendMail;\r
180         OnOK();\r
181 }\r
182 \r
183 void CFormatPatchDlg::OnBnClickedRadio()\r
184 {\r
185         // TODO: Add your control notification handler code here\r
186         int radio=this->GetCheckedRadioButton(IDC_RADIO_SINCE,IDC_RADIO_RANGE);\r
187         m_cSince.EnableWindow(FALSE);\r
188         m_cNum.EnableWindow(FALSE);\r
189         m_cFrom.EnableWindow(FALSE);\r
190         m_cTo.EnableWindow(FALSE);\r
191         switch(radio)\r
192         {\r
193         case IDC_RADIO_SINCE:\r
194                 m_cSince.EnableWindow(TRUE);\r
195                 break;\r
196         case IDC_RADIO_NUM:\r
197                 m_cNum.EnableWindow(TRUE);\r
198                 break;\r
199         case IDC_RADIO_RANGE:\r
200                 m_cFrom.EnableWindow(TRUE);\r
201                 m_cTo.EnableWindow(TRUE);\r
202         }\r
203 }\r
204 \r
205 void CFormatPatchDlg::OnBnClickedButtonRef()\r
206 {\r
207         if(CBrowseRefsDlg::PickRefForCombo(&m_cSince, gPickRef_NoTag))\r
208         {\r
209                 CheckRadioButton(IDC_RADIO_SINCE, IDC_RADIO_RANGE, IDC_RADIO_SINCE);\r
210                 OnBnClickedRadio();\r
211         }\r
212 }\r