OSDN Git Service

Merge with stable
[winmerge-jp/winmerge-jp.git] / Src / ConfirmFolderCopyDlg.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 //    License (GPLv2+):
3 //    This program is free software; you can redistribute it and/or modify
4 //    it under the terms of the GNU General Public License as published by
5 //    the Free Software Foundation; either version 2 of the License, or
6 //    (at your option) any later version.
7 //
8 //    This program is distributed in the hope that it will be useful, but
9 //    WITHOUT ANY WARRANTY; without even the implied warranty of
10 //    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 //    General Public License for more details.
12 //
13 //    You should have received a copy of the GNU General Public License
14 //    along with this program; if not, write to the Free Software
15 //    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16 /////////////////////////////////////////////////////////////////////////////
17 /**
18  * @file  ConfirmFolderCopyDlg.cpp
19  *
20  * @brief Implementation file for ConfirmFolderCopyDlg dialog
21  */
22
23 #include "stdafx.h"
24 #include "ConfirmFolderCopyDlg.h"
25 #include "Merge.h"
26 #include "DDXHelper.h"
27
28 #ifdef _DEBUG
29 #define new DEBUG_NEW
30 #undef THIS_FILE
31 static char THIS_FILE[] = __FILE__;
32 #endif
33
34
35 // ConfirmFolderCopyDlg dialog
36
37 IMPLEMENT_DYNAMIC(ConfirmFolderCopyDlg, CDialog)
38 ConfirmFolderCopyDlg::ConfirmFolderCopyDlg(CWnd* pParent /*=NULL*/)
39         : CDialog(ConfirmFolderCopyDlg::IDD, pParent)
40 {
41 }
42
43 ConfirmFolderCopyDlg::~ConfirmFolderCopyDlg()
44 {
45 }
46
47 void ConfirmFolderCopyDlg::DoDataExchange(CDataExchange* pDX)
48 {
49         CDialog::DoDataExchange(pDX);
50         //{{AFX_DATA_MAP(ConfirmFolderCopyDlg)
51         DDX_Text(pDX, IDC_FLDCONFIRM_FROM_TEXT, m_fromText);
52         DDX_Text(pDX, IDC_FLDCONFIRM_TO_TEXT, m_toText);
53         DDX_Text(pDX, IDC_FLDCONFIRM_FROM_PATH, m_fromPath);
54         DDX_Text(pDX, IDC_FLDCONFIRM_TO_PATH, m_toPath);
55         DDX_Text(pDX, IDC_FLDCONFIRM_QUERY, m_question);
56         //}}AFX_DATA_MAP
57 }
58
59
60 BEGIN_MESSAGE_MAP(ConfirmFolderCopyDlg, CDialog)
61         ON_BN_CLICKED(IDNO, OnBnClickedNo)
62         ON_BN_CLICKED(IDYES, OnBnClickedYes)
63 END_MESSAGE_MAP()
64
65
66 // ConfirmFolderCopyDlg message handlers
67
68 /**
69  * @brief Handler for WM_INITDIALOG; conventional location to initialize
70  * controls. At this point dialog and control windows exist.
71  */
72 BOOL ConfirmFolderCopyDlg::OnInitDialog() 
73 {
74         theApp.TranslateDialog(m_hWnd);
75         CDialog::OnInitDialog();
76
77         // Load warning icon
78         // TODO: we can have per-action icons?
79         HICON icon = AfxGetApp()->LoadStandardIcon(IDI_EXCLAMATION);
80         CStatic * pIcon = (CStatic *) GetDlgItem(IDC_FLDCONFIRM_ICON);
81         pIcon->SetIcon(icon);
82
83         if (!m_caption.empty())
84                 SetWindowText(m_caption.c_str());
85
86         // setup handler for resizing this dialog       
87         m_constraint.InitializeCurrentSize(this);
88         // configure how individual controls adjust when dialog resizes
89         m_constraint.ConstrainItem(IDC_FLDCONFIRM_FROM_PATH, 0, 1, 0, 0); // grows right
90         m_constraint.ConstrainItem(IDC_FLDCONFIRM_TO_PATH, 0, 1, 0, 0); // grows right
91         // IDC_SAVECLOSING_DISCARDALL doesn't move
92         m_constraint.ConstrainItem(IDYES, 1, 0, 0, 0); // slides right
93         m_constraint.ConstrainItem(IDNO, 1, 0, 0, 0); // slides right
94         m_constraint.DisallowHeightGrowth();
95         m_constraint.SubclassWnd(); // install subclassing
96         // persist size via registry
97         m_constraint.LoadPosition(_T("ResizeableDialogs"), _T("FolderCopyConfirmDlg"), false);
98
99         return TRUE;  // return TRUE unless you set the focus to a control
100                       // EXCEPTION: OCX Property Pages should return FALSE
101 }
102
103 /**
104  * @brief Close dialog when No button is clicked.
105  */
106 void ConfirmFolderCopyDlg::OnBnClickedNo()
107 {
108         EndDialog(IDNO);
109 }
110
111 /**
112  * @brief Close dialog when Yes button is clicked.
113  */
114 void ConfirmFolderCopyDlg::OnBnClickedYes()
115 {
116         EndDialog(IDYES);
117 }