OSDN Git Service

5b613fd9302b3edd48de7c2052ed4bc5c810716d
[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 // CFormatPatchDlg dialog\r
10 \r
11 IMPLEMENT_DYNAMIC(CFormatPatchDlg, CResizableStandAloneDialog)\r
12 \r
13 CFormatPatchDlg::CFormatPatchDlg(CWnd* pParent /*=NULL*/)\r
14         : CResizableStandAloneDialog(CFormatPatchDlg::IDD, pParent),\r
15         m_regSendMail(_T("Software\\TortoiseGit\\TortoiseProc\\FormatPatch\\SendMail"),0)\r
16 {\r
17         m_Num=1;\r
18         this->m_bSendMail = m_regSendMail;\r
19 }\r
20 \r
21 CFormatPatchDlg::~CFormatPatchDlg()\r
22 {\r
23 }\r
24 \r
25 void CFormatPatchDlg::DoDataExchange(CDataExchange* pDX)\r
26 {\r
27         CDialog::DoDataExchange(pDX);\r
28         DDX_Control(pDX, IDC_COMBOBOXEX_DIR,    m_cDir);\r
29         DDX_Control(pDX, IDC_COMBOBOXEX_SINCE,  m_cSince);\r
30         DDX_Control(pDX, IDC_COMBOBOXEX_FROM,   m_cFrom);\r
31         DDX_Control(pDX, IDC_COMBOBOXEX_TO,             m_cTo);\r
32         DDX_Control(pDX, IDC_EDIT_NUM,                  m_cNum);\r
33 \r
34         DDX_Text(pDX,IDC_EDIT_NUM,m_Num);\r
35 \r
36         DDX_Text(pDX, IDC_COMBOBOXEX_DIR,       m_Dir);\r
37         DDX_Text(pDX, IDC_COMBOBOXEX_SINCE,     m_Since);\r
38         DDX_Text(pDX, IDC_COMBOBOXEX_FROM,      m_From);\r
39         DDX_Text(pDX, IDC_COMBOBOXEX_TO,        m_To);\r
40         \r
41         DDX_Check(pDX, IDC_CHECK_SENDMAIL, m_bSendMail);\r
42 }\r
43 \r
44 \r
45 BEGIN_MESSAGE_MAP(CFormatPatchDlg, CResizableStandAloneDialog)\r
46         ON_BN_CLICKED(IDC_BUTTON_DIR, &CFormatPatchDlg::OnBnClickedButtonDir)\r
47         ON_BN_CLICKED(IDC_BUTTON_FROM, &CFormatPatchDlg::OnBnClickedButtonFrom)\r
48         ON_BN_CLICKED(IDC_BUTTON_TO, &CFormatPatchDlg::OnBnClickedButtonTo)\r
49         ON_BN_CLICKED(IDOK, &CFormatPatchDlg::OnBnClickedOk)\r
50         ON_BN_CLICKED(IDC_RADIO_SINCE, &CFormatPatchDlg::OnBnClickedRadio)\r
51         ON_BN_CLICKED(IDC_RADIO_NUM, &CFormatPatchDlg::OnBnClickedRadio)\r
52         ON_BN_CLICKED(IDC_RADIO_RANGE, &CFormatPatchDlg::OnBnClickedRadio)\r
53 END_MESSAGE_MAP()\r
54 \r
55 BOOL CFormatPatchDlg::OnInitDialog()\r
56 {\r
57         CResizableStandAloneDialog::OnInitDialog();\r
58         \r
59         AddAnchor(IDC_GROUP_DIR, TOP_LEFT, TOP_RIGHT);\r
60         AddAnchor(IDC_COMBOBOXEX_DIR,TOP_LEFT, TOP_RIGHT);\r
61         AddAnchor(IDC_BUTTON_DIR, TOP_RIGHT);\r
62 \r
63         AddAnchor(IDC_GROUP_VERSION, TOP_LEFT, TOP_RIGHT);\r
64         AddAnchor(IDC_COMBOBOXEX_SINCE, TOP_LEFT, TOP_RIGHT);\r
65         AddAnchor(IDC_EDIT_NUM, TOP_LEFT, TOP_RIGHT);\r
66         AddAnchor(IDC_SPIN_NUM, TOP_RIGHT);\r
67 \r
68         AddAnchor(IDC_COMBOBOXEX_FROM, TOP_LEFT, TOP_RIGHT);\r
69         AddAnchor(IDC_COMBOBOXEX_TO, TOP_LEFT, TOP_RIGHT);\r
70 \r
71         AddAnchor(IDC_BUTTON_FROM,  TOP_RIGHT);\r
72         AddAnchor(IDC_BUTTON_TO,        TOP_RIGHT);\r
73         AddAnchor(IDC_CHECK_SENDMAIL,BOTTOM_LEFT);\r
74         AddAnchor(IDOK,BOTTOM_RIGHT);\r
75         AddAnchor(IDCANCEL,BOTTOM_RIGHT);\r
76 \r
77         this->AddOthersToAnchor();\r
78 \r
79         m_cDir.SetPathHistory(TRUE);\r
80         m_cDir.LoadHistory(_T("Software\\TortoiseGit\\History\\FormatPatchURLS"), _T("path"));\r
81         m_cDir.SetCurSel(0);\r
82 \r
83         STRING_VECTOR list;\r
84         g_Git.GetBranchList(list,NULL,CGit::BRANCH_ALL);\r
85         m_cSince.AddString(list);\r
86 \r
87         m_cFrom.LoadHistory(_T("Software\\TortoiseGit\\History\\FormatPatchFromURLS"), _T("ver"));\r
88         m_cFrom.SetCurSel(0);\r
89 \r
90         m_cTo.LoadHistory(_T("Software\\TortoiseGit\\History\\FormatPatchToURLS"), _T("ver"));\r
91         m_cTo.SetCurSel(0);\r
92 \r
93         this->CheckRadioButton(IDC_RADIO_SINCE,IDC_RADIO_RANGE,IDC_RADIO_SINCE);\r
94         \r
95         OnBnClickedRadio();\r
96 \r
97         EnableSaveRestore(_T("FormatPatchDlg"));\r
98         return TRUE;\r
99 }\r
100 // CFormatPatchDlg message handlers\r
101 \r
102 void CFormatPatchDlg::OnBnClickedButtonDir()\r
103 {\r
104         // TODO: Add your control notification handler code here\r
105         CBrowseFolder browseFolder;\r
106         browseFolder.m_style = BIF_EDITBOX | BIF_NEWDIALOGSTYLE | BIF_RETURNFSANCESTORS | BIF_RETURNONLYFSDIRS;\r
107         CString strCloneDirectory;\r
108         this->UpdateData(TRUE);\r
109         strCloneDirectory=m_Dir;\r
110         if (browseFolder.Show(GetSafeHwnd(), strCloneDirectory) == CBrowseFolder::OK) \r
111         {\r
112                 m_Dir=strCloneDirectory;\r
113                 this->UpdateData(FALSE);\r
114         }\r
115 }\r
116 \r
117 void CFormatPatchDlg::OnBnClickedButtonFrom()\r
118 {\r
119         // TODO: Add your control notification handler code here\r
120 }\r
121 \r
122 void CFormatPatchDlg::OnBnClickedButtonTo()\r
123 {\r
124         // TODO: Add your control notification handler code here\r
125 }\r
126 \r
127 void CFormatPatchDlg::OnBnClickedOk()\r
128 {\r
129         // TODO: Add your control notification handler code here\r
130 \r
131         m_cDir.SaveHistory();\r
132         m_cFrom.SaveHistory();\r
133         m_cTo.SaveHistory();\r
134         this->UpdateData(TRUE);\r
135         this->m_Radio=GetCheckedRadioButton(IDC_RADIO_SINCE,IDC_RADIO_RANGE);\r
136 \r
137         m_regSendMail=this->m_bSendMail;\r
138         OnOK();\r
139 }\r
140 \r
141 void CFormatPatchDlg::OnBnClickedRadio()\r
142 {\r
143         // TODO: Add your control notification handler code here\r
144         int radio=this->GetCheckedRadioButton(IDC_RADIO_SINCE,IDC_RADIO_RANGE);\r
145         m_cSince.EnableWindow(FALSE);\r
146         m_cNum.EnableWindow(FALSE);\r
147         m_cFrom.EnableWindow(FALSE);\r
148         m_cTo.EnableWindow(FALSE);\r
149         switch(radio)\r
150         {\r
151         case IDC_RADIO_SINCE:\r
152                 m_cSince.EnableWindow(TRUE);\r
153                 break;\r
154         case IDC_RADIO_NUM:\r
155                 m_cNum.EnableWindow(TRUE);\r
156                 break;\r
157         case IDC_RADIO_RANGE:\r
158                 m_cFrom.EnableWindow(TRUE);\r
159                 m_cTo.EnableWindow(TRUE);\r
160         }\r
161 }\r