-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathMergeComment.cpp
More file actions
186 lines (148 loc) · 4.17 KB
/
Copy pathMergeComment.cpp
File metadata and controls
186 lines (148 loc) · 4.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
// MergeComment.cpp : implementation file
//
#include "stdafx.h"
#include "renlib.h"
#include "MergeComment.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// MergeComment dialog
namespace
{
UINT getDialogId(MergeComment::Kind kind)
{
UINT id = 0;
switch (kind)
{
case MergeComment::ONE_LINE_COMMENT:
{
id = IDD_MERGE_ONELINE_COMMENT;
break;
}
case MergeComment::MULTI_LINE_COMMENT:
{
id = IDD_MERGE_MULTI_LINE_COMMENT;
break;
}
case MergeComment::BOARD_TEXT:
{
id = IDD_MERGE_BOARD_TEXT;
break;
}
}
return id;
}
}
MergeComment::MergeComment(const CString& currentComment, const CString& newComment, MergeComment::Kind kind)
: CDialog(getDialogId(kind), NULL),
mKind(kind),
mCurrentComment(currentComment),
mNewComment(newComment),
mSelection(CURRENT),
mApplySelectionToAll(false)
{
//{{AFX_DATA_INIT(MergeComment)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
void MergeComment::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(MergeComment)
DDX_Control(pDX, IDC_MERGE_ALL, mApplyToAll);
DDX_Control(pDX, IDC_SELECT_CURRENT, mSelectCurrent);
DDX_Control(pDX, IDC_SELECT_NEW, mSelectNew);
DDX_Control(pDX, IDC_SELECT_COMBINED, mSelectCombined);
DDX_Control(pDX, IDC_EDIT_NEW, mNew);
DDX_Control(pDX, IDC_EDIT_CURRENT, mCurrent);
DDX_Control(pDX, IDC_EDIT_COMBINED, mCombinedComment);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(MergeComment, CDialog)
//{{AFX_MSG_MAP(MergeComment)
ON_BN_CLICKED(IDC_SELECT_CURRENT, OnCurrent)
ON_BN_CLICKED(IDC_SELECT_NEW, OnNew)
ON_BN_CLICKED(IDC_SELECT_COMBINED, OnCombined)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// MergeComment message handlers
BOOL MergeComment::OnInitDialog()
{
CDialog::OnInitDialog();
mCurrent.SetWindowText(mCurrentComment);
mNew.SetWindowText(mNewComment);
CString strDelimiter(mKind == MULTI_LINE_COMMENT ? "\r\n" : " ");
mCombinedComment.SetWindowText(mCurrentComment + strDelimiter + mNewComment);
updateControls();
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
//----------------------------------------------------------------------------
void MergeComment::OnCurrent()
{
mSelection = CURRENT;
updateControls();
}
//----------------------------------------------------------------------------
void MergeComment::OnNew()
{
mSelection = NEW;
updateControls();
}
//----------------------------------------------------------------------------
void MergeComment::OnCombined()
{
mSelection = COMBINED;
updateControls();
}
//----------------------------------------------------------------------------
void MergeComment::updateControls()
{
mSelectCurrent.SetCheck(mSelection == CURRENT);
mSelectNew.SetCheck(mSelection == NEW);
mSelectCombined.SetCheck(mSelection == COMBINED);
mCurrent.EnableWindow(mSelectCurrent.GetCheck());
mNew.EnableWindow(mSelectNew.GetCheck());
mCombinedComment.EnableWindow(mSelectCombined.GetCheck());
}
//----------------------------------------------------------------------------
CString MergeComment::getMergedComment()
{
return mCurrentComment;
}
//----------------------------------------------------------------------------
MergeComment::Selection
MergeComment::getSelection()
{
return mSelection;
}
//----------------------------------------------------------------------------
bool MergeComment::getApplySelectionToAll()
{
return mApplySelectionToAll;
}
//----------------------------------------------------------------------------
void MergeComment::OnOK()
{
CDialog::OnOK();
if (mCurrent.IsWindowEnabled())
{
mCurrent.GetWindowText(mCurrentComment);
}
else if (mNew.IsWindowEnabled())
{
mNew.GetWindowText(mCurrentComment);
}
else if (mCombinedComment.IsWindowEnabled())
{
mCombinedComment.GetWindowText(mCurrentComment);
}
if (mApplyToAll.GetCheck() == 1)
{
mApplySelectionToAll = true;
}
}