OSDN Git Service

Merge myapi_overlay.
[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         EnableSaveRestore(_T("FormatPatchDlg"));\r
91         return TRUE;\r
92 }\r
93 // CFormatPatchDlg message handlers\r
94 \r
95 void CFormatPatchDlg::OnBnClickedButtonDir()\r
96 {\r
97         // TODO: Add your control notification handler code here\r
98         CBrowseFolder browseFolder;\r
99         browseFolder.m_style = BIF_EDITBOX | BIF_NEWDIALOGSTYLE | BIF_RETURNFSANCESTORS | BIF_RETURNONLYFSDIRS;\r
100         CString strCloneDirectory;\r
101         this->UpdateData(TRUE);\r
102         strCloneDirectory=m_Dir;\r
103         if (browseFolder.Show(GetSafeHwnd(), strCloneDirectory) == CBrowseFolder::OK) \r
104         {\r
105                 m_Dir=strCloneDirectory;\r
106                 this->UpdateData(FALSE);\r
107         }\r
108 }\r
109 \r
110 void CFormatPatchDlg::OnBnClickedButtonFrom()\r
111 {\r
112         // TODO: Add your control notification handler code here\r
113 }\r
114 \r
115 void CFormatPatchDlg::OnBnClickedButtonTo()\r
116 {\r
117         // TODO: Add your control notification handler code here\r
118 }\r
119 \r
120 void CFormatPatchDlg::OnBnClickedOk()\r
121 {\r
122         // TODO: Add your control notification handler code here\r
123 \r
124         m_cDir.SaveHistory();\r
125         m_cFrom.SaveHistory();\r
126         m_cTo.SaveHistory();\r
127         this->UpdateData(TRUE);\r
128         this->m_Radio=GetCheckedRadioButton(IDC_RADIO_SINCE,IDC_RADIO_RANGE);\r
129         OnOK();\r
130 }\r
131 \r
132 void CFormatPatchDlg::OnBnClickedRadio()\r
133 {\r
134         // TODO: Add your control notification handler code here\r
135         int radio=this->GetCheckedRadioButton(IDC_RADIO_SINCE,IDC_RADIO_RANGE);\r
136         m_cSince.EnableWindow(FALSE);\r
137         m_cNum.EnableWindow(FALSE);\r
138         m_cFrom.EnableWindow(FALSE);\r
139         m_cTo.EnableWindow(FALSE);\r
140         switch(radio)\r
141         {\r
142         case IDC_RADIO_SINCE:\r
143                 m_cSince.EnableWindow(TRUE);\r
144                 break;\r
145         case IDC_RADIO_NUM:\r
146                 m_cNum.EnableWindow(TRUE);\r
147                 break;\r
148         case IDC_RADIO_RANGE:\r
149                 m_cFrom.EnableWindow(TRUE);\r
150                 m_cTo.EnableWindow(TRUE);\r
151         }\r
152 }\r