1 /////////////////////////////////////////////////////////////////////////////
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.
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.
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 /////////////////////////////////////////////////////////////////////////////
18 * @file SaveClosingDlg.cpp
20 * @brief Implementation file for SaveClosingDlg dialog
22 // ID line follows -- this is updated by SVN
23 // $Id: SaveClosingDlg.cpp 4704 2007-11-03 12:10:48Z jtuc $
26 #include "SaveClosingDlg.h"
32 static char THIS_FILE[] = __FILE__;
35 /////////////////////////////////////////////////////////////////////////////
36 // SaveClosingDlg dialog
38 IMPLEMENT_DYNAMIC(SaveClosingDlg, CDialog)
42 * @param [in] pParent Dialog's parent window.
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)
56 void SaveClosingDlg::DoDataExchange(CDataExchange* pDX)
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);
70 BEGIN_MESSAGE_MAP(SaveClosingDlg, CDialog)
71 //{{AFX_MSG_MAP(SaveClosingDlg)
72 ON_BN_CLICKED(IDC_SAVECLOSING_DISCARDALL, OnDiscardAll)
77 /////////////////////////////////////////////////////////////////////////////
78 // SaveClosingDlg message handlers
81 * @brief Initialize dialog.
82 * @return Always TRUE.
84 BOOL SaveClosingDlg::OnInitDialog()
86 theApp.TranslateDialog(m_hWnd);
87 CDialog::OnInitDialog();
89 GetDlgItem(IDC_SAVECLOSING_SAVELEFT)->SetFocus();
92 // Left items disabled move focus to middle side items
93 GetDlgItem(IDC_SAVECLOSING_SAVEMIDDLE)->SetFocus();
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);
101 if (!m_bAskForMiddle)
103 // Middle items disabled move focus to right side items
105 GetDlgItem(IDC_SAVECLOSING_SAVERIGHT)->SetFocus();
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);
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);
121 if (m_bDisableCancel)
123 GetDlgItem(IDCANCEL)->EnableWindow(FALSE);
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
148 return FALSE; // return TRUE unless you set the focus to a control
149 // EXCEPTION: OCX Property Pages should return FALSE
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?
157 void SaveClosingDlg::DoAskFor(BOOL bLeft /*= FALSE*/, BOOL bMiddle /*= FALSE*/, BOOL bRight /*= FALSE*/)
159 m_bAskForLeft = bLeft;
160 m_bAskForMiddle = bMiddle;
161 m_bAskForRight = bRight;
165 * @brief Called when 'Discard All' button is selected.
167 void SaveClosingDlg::OnDiscardAll()
169 m_leftSave = SAVECLOSING_DISCARD;
170 m_middleSave = SAVECLOSING_DISCARD;
171 m_rightSave = SAVECLOSING_DISCARD;