OSDN Git Service

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