-
Notifications
You must be signed in to change notification settings - Fork 1
/
ChildFrm.cpp
162 lines (126 loc) · 4.24 KB
/
ChildFrm.cpp
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
// ChildFrm.cpp : implementation of the CChildFrame class
//
#include "stdafx.h"
#include "cedtHeader.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CChildFrame
IMPLEMENT_DYNCREATE(CChildFrame, CMDIChildWnd)
BEGIN_MESSAGE_MAP(CChildFrame, CMDIChildWnd)
//{{AFX_MSG_MAP(CChildFrame)
ON_WM_DESTROY()
ON_WM_MDIACTIVATE()
ON_WM_CREATE()
ON_COMMAND(ID_WINDOW_CLOSE, OnWindowClose)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CChildFrame construction/destruction
CChildFrame::CChildFrame()
{
}
CChildFrame::~CChildFrame()
{
}
/////////////////////////////////////////////////////////////////////////////
// CChildFrame diagnostics
#ifdef _DEBUG
void CChildFrame::AssertValid() const
{
CMDIChildWnd::AssertValid();
}
void CChildFrame::Dump(CDumpContext& dc) const
{
CMDIChildWnd::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CChildFrame operations
CWnd * CChildFrame::GetNeighborPane(CWnd * pWnd)
{
BOOL bChild; INT nRowIndex, nColIndex;
bChild = m_wndSplitter.IsChildPane(pWnd, nRowIndex, nColIndex); ASSERT( bChild );
if( nColIndex > 0 ) return m_wndSplitter.GetPane( nRowIndex, nColIndex-1 );
if( nRowIndex > 0 ) return m_wndSplitter.GetPane( nRowIndex-1, nColIndex );
return pWnd;
}
void CChildFrame::SetScrollPosSyncAllPanes(CWnd * pWnd, INT nPosX, INT nPosY)
{
BOOL bChild; INT i, j, nRowIndex, nColIndex, nRowCount, nColCount;
bChild = m_wndSplitter.IsChildPane(pWnd, nRowIndex, nColIndex); ASSERT( bChild );
nRowCount = m_wndSplitter.GetRowCount();
for( i = 0; i < nRowCount; i++ ) {
CCedtView * pView = (CCedtView *)m_wndSplitter.GetPane(i, nColIndex);
pView->SetScrollPosX( nPosX );
}
nColCount = m_wndSplitter.GetColumnCount();
for( j = 0; j < nColCount; j++ ) {
CCedtView * pView = (CCedtView *)m_wndSplitter.GetPane(nRowIndex, j);
pView->SetScrollPosY( nPosY );
}
}
void CChildFrame::UpdateAllPanesInTheSameRow(CWnd * pWnd)
{
BOOL bChild; INT j, nRowIndex, nColIndex, nColCount;
bChild = m_wndSplitter.IsChildPane(pWnd, nRowIndex, nColIndex); ASSERT( bChild );
nColCount = m_wndSplitter.GetColumnCount();
for( j = 0; j < nColCount; j++ ) {
CCedtView * pView = (CCedtView *)m_wndSplitter.GetPane(nRowIndex, j);
if( pView != pWnd ) pView->Invalidate();
}
}
void CChildFrame::UpdateAllPanesSharingScrollBar(CWnd * pWnd)
{
BOOL bChild; INT i, j, nRowIndex, nColIndex, nRowCount, nColCount;
bChild = m_wndSplitter.IsChildPane(pWnd, nRowIndex, nColIndex); ASSERT( bChild );
nRowCount = m_wndSplitter.GetRowCount();
for( i = 0; i < nRowCount; i++ ) {
CCedtView * pView = (CCedtView *)m_wndSplitter.GetPane(i, nColIndex);
if( pView != pWnd ) pView->Invalidate();
}
nColCount = m_wndSplitter.GetColumnCount();
for( j = 0; j < nColCount; j++ ) {
CCedtView * pView = (CCedtView *)m_wndSplitter.GetPane(nRowIndex, j);
if( pView != pWnd ) pView->Invalidate();
}
}
/////////////////////////////////////////////////////////////////////////////
// CChildFrame message handlers
BOOL CChildFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
{
// return CMDIChildWnd::OnCreateClient(lpcs, pContext);
return m_wndSplitter.Create(this, 2, 2, CSize(10, 10), pContext);
}
int CChildFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if(CMDIChildWnd::OnCreate(lpCreateStruct) == -1) return -1;
// insert into file selection tab
CMainFrame * pMainFrame = (CMainFrame *)AfxGetMainWnd();
pMainFrame->InsertMDIFileTab(this);
return 0;
}
void CChildFrame::OnDestroy()
{
// delete from file tab
CMainFrame * pMainFrame = (CMainFrame *)AfxGetMainWnd();
pMainFrame->DeleteMDIFileTab(this);
CMDIChildWnd::OnDestroy();
}
void CChildFrame::OnMDIActivate(BOOL bActivate, CWnd* pActivateWnd, CWnd* pDeactivateWnd)
{
CMDIChildWnd::OnMDIActivate(bActivate, pActivateWnd, pDeactivateWnd);
if( bActivate ) {
// set this active file tab
CMainFrame * pMainFrame = (CMainFrame *)AfxGetMainWnd();
pMainFrame->SetActiveFileTab(this);
}
}
void CChildFrame::OnWindowClose()
{
CDocument * pDoc = GetActiveDocument(); ASSERT( pDoc );
if( pDoc->CanCloseFrame(this) ) MDIDestroy();
}