OSDN Git Service

* Use standard order of header files
[winmerge-jp/winmerge-jp.git] / Src / SaveClosingDlg.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  SaveClosingDlg.cpp
19  *
20  * @brief Implementation file for SaveClosingDlg dialog
21  */
22 // ID line follows -- this is updated by SVN
23 // $Id: SaveClosingDlg.cpp 4704 2007-11-03 12:10:48Z jtuc $
24
25 #include "stdafx.h"
26 #include "SaveClosingDlg.h"
27 #include "Merge.h"
28
29 #ifdef _DEBUG
30 #define new DEBUG_NEW
31 #undef THIS_FILE
32 static char THIS_FILE[] = __FILE__;
33 #endif
34
35 /////////////////////////////////////////////////////////////////////////////
36 // SaveClosingDlg dialog
37
38 IMPLEMENT_DYNAMIC(SaveClosingDlg, CDialog)
39
40 /**
41  * @brief Constructor.
42  * @param [in] pParent Dialog's parent window.
43  */
44 SaveClosingDlg::SaveClosingDlg(CWnd* pParent /*=NULL*/)
45  : CDialog(SaveClosingDlg::IDD, pParent)
46  , m_leftSave(SAVECLOSING_SAVE)
47  , m_middleSave(SAVECLOSING_SAVE)
48  , m_rightSave(SAVECLOSING_SAVE)
49  , m_bAskForLeft(FALSE)
50  , m_bAskForMiddle(FALSE)
51  , m_bAskForRight(FALSE)
52  , m_bDisableCancel(FALSE)
53 {
54 }
55
56 void SaveClosingDlg::DoDataExchange(CDataExchange* pDX)
57 {
58         CDialog::DoDataExchange(pDX);
59         //{{AFX_DATA_MAP(SaveClosingDlg)
60         DDX_Text(pDX, IDC_SAVECLOSING_LEFTFILE, m_sLeftFile);
61         DDX_Text(pDX, IDC_SAVECLOSING_MIDDLEFILE, m_sMiddleFile);
62         DDX_Text(pDX, IDC_SAVECLOSING_RIGHTFILE, m_sRightFile);
63         DDX_Radio(pDX, IDC_SAVECLOSING_SAVELEFT, m_leftSave);
64         DDX_Radio(pDX, IDC_SAVECLOSING_SAVEMIDDLE, m_middleSave);
65         DDX_Radio(pDX, IDC_SAVECLOSING_SAVERIGHT, m_rightSave);
66         //}}AFX_DATA_MAP
67 }
68
69
70 BEGIN_MESSAGE_MAP(SaveClosingDlg, CDialog)
71         //{{AFX_MSG_MAP(SaveClosingDlg)
72         ON_BN_CLICKED(IDC_SAVECLOSING_DISCARDALL, OnDiscardAll)
73         //}}AFX_MSG_MAP
74 END_MESSAGE_MAP()
75
76
77 /////////////////////////////////////////////////////////////////////////////
78 // SaveClosingDlg message handlers
79
80 /**
81  * @brief Initialize dialog.
82  * @return Always TRUE.
83  */
84 BOOL SaveClosingDlg::OnInitDialog() 
85 {
86         theApp.TranslateDialog(m_hWnd);
87         CDialog::OnInitDialog();
88
89         GetDlgItem(IDC_SAVECLOSING_SAVELEFT)->SetFocus();
90         if (!m_bAskForLeft)
91         {
92                 // Left items disabled move focus to middle side items
93                 GetDlgItem(IDC_SAVECLOSING_SAVEMIDDLE)->SetFocus();
94
95                 GetDlgItem(IDC_SAVECLOSING_LEFTFRAME)->EnableWindow(FALSE);
96                 GetDlgItem(IDC_SAVECLOSING_LEFTFILE)->EnableWindow(FALSE);
97                 GetDlgItem(IDC_SAVECLOSING_SAVELEFT)->EnableWindow(FALSE);
98                 GetDlgItem(IDC_SAVECLOSING_DISCARDLEFT)->EnableWindow(FALSE);
99         }
100
101         if (!m_bAskForMiddle)
102         {
103                 // Middle items disabled move focus to right side items
104                 if (!m_bAskForLeft)
105                         GetDlgItem(IDC_SAVECLOSING_SAVERIGHT)->SetFocus();
106
107                 GetDlgItem(IDC_SAVECLOSING_MIDDLEFRAME)->EnableWindow(FALSE);
108                 GetDlgItem(IDC_SAVECLOSING_MIDDLEFILE)->EnableWindow(FALSE);
109                 GetDlgItem(IDC_SAVECLOSING_SAVEMIDDLE)->EnableWindow(FALSE);
110                 GetDlgItem(IDC_SAVECLOSING_DISCARDMIDDLE)->EnableWindow(FALSE);
111         }
112         
113         if (!m_bAskForRight)
114         {
115                 GetDlgItem(IDC_SAVECLOSING_RIGHTFRAME)->EnableWindow(FALSE);
116                 GetDlgItem(IDC_SAVECLOSING_RIGHTFILE)->EnableWindow(FALSE);
117                 GetDlgItem(IDC_SAVECLOSING_SAVERIGHT)->EnableWindow(FALSE);
118                 GetDlgItem(IDC_SAVECLOSING_DISCARDRIGHT)->EnableWindow(FALSE);
119         }
120
121         if (m_bDisableCancel)
122         {
123                 GetDlgItem(IDCANCEL)->EnableWindow(FALSE);
124         }
125
126         // setup handler for resizing this dialog       
127         m_constraint.InitializeCurrentSize(this);
128         // configure how individual controls adjust when dialog resizes
129         m_constraint.ConstrainItem(IDC_SAVECLOSING_LEFTFRAME, 0, 1, 0, 0); // grows right
130         m_constraint.ConstrainItem(IDC_SAVECLOSING_LEFTFILE, 0, 1, 0, 0); // grows right
131         m_constraint.ConstrainItem(IDC_SAVECLOSING_SAVELEFT, 0, 1, 0, 0); // grows right
132         m_constraint.ConstrainItem(IDC_SAVECLOSING_DISCARDLEFT, 0, 1, 0, 0); // grows right
133         m_constraint.ConstrainItem(IDC_SAVECLOSING_MIDDLEFRAME, 0, 1, 0, 0); // grows right
134         m_constraint.ConstrainItem(IDC_SAVECLOSING_MIDDLEFILE, 0, 1, 0, 0); // grows right
135         m_constraint.ConstrainItem(IDC_SAVECLOSING_SAVEMIDDLE, 0, 1, 0, 0); // grows right
136         m_constraint.ConstrainItem(IDC_SAVECLOSING_DISCARDMIDDLE, 0, 1, 0, 0); // grows right
137         m_constraint.ConstrainItem(IDC_SAVECLOSING_RIGHTFRAME, 0, 1, 0, 0); // grows right
138         m_constraint.ConstrainItem(IDC_SAVECLOSING_RIGHTFILE, 0, 1, 0, 0); // grows right
139         m_constraint.ConstrainItem(IDC_SAVECLOSING_SAVERIGHT, 0, 1, 0, 0); // grows right
140         m_constraint.ConstrainItem(IDC_SAVECLOSING_DISCARDRIGHT, 0, 1, 0, 0); // grows right
141         // IDC_SAVECLOSING_DISCARDALL doesn't move
142         m_constraint.ConstrainItem(IDOK, 1, 0, 0, 0); // slides right
143         m_constraint.ConstrainItem(IDCANCEL, 1, 0, 0, 0); // slides right
144         m_constraint.DisallowHeightGrowth();
145         m_constraint.SubclassWnd(); // install subclassing
146         m_constraint.LoadPosition(_T("ResizeableDialogs"), _T("SaveClosingDlg"), false); // persist size via registry
147
148         return FALSE;  // return TRUE unless you set the focus to a control
149                       // EXCEPTION: OCX Property Pages should return FALSE
150 }
151
152 /** 
153  * @brief Select files to ask about saving.
154  * @param [in] bLeft Do we ask about left-side file?
155  * @param [in] bRight Do we ask about right-side file?
156  */
157 void SaveClosingDlg::DoAskFor(BOOL bLeft /*= FALSE*/, BOOL bMiddle /*= FALSE*/, BOOL bRight /*= FALSE*/)
158 {
159         m_bAskForLeft = bLeft;
160         m_bAskForMiddle = bMiddle;
161         m_bAskForRight = bRight;
162 }
163
164 /** 
165  * @brief Called when 'Discard All' button is selected.
166  */
167 void SaveClosingDlg::OnDiscardAll()
168 {
169         m_leftSave = SAVECLOSING_DISCARD;
170         m_middleSave = SAVECLOSING_DISCARD;
171         m_rightSave = SAVECLOSING_DISCARD;
172         UpdateData(FALSE);
173         OnOK();
174 }