-
Notifications
You must be signed in to change notification settings - Fork 0
/
TabbedView.cpp
153 lines (122 loc) · 3.69 KB
/
TabbedView.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
#include "stdafx.h"
#include "Modeler1.h"
#include "Modeler1Doc.h"
#include "TabbedView.h"
#include "Modeler1View.h"
#include "Modeler1SourceView.h"
//#include "SourceCodeView.h"
#include "MainFrm.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CTabbedView
IMPLEMENT_DYNCREATE(CTabbedView, CTabView)
BEGIN_MESSAGE_MAP(CTabbedView, CTabView)
ON_WM_CREATE()
ON_WM_ERASEBKGND()
// Standard printing commands
ON_COMMAND(ID_FILE_PRINT, CTabView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT, CTabView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, OnFilePrintPreview)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CTabbedView construction/destruction
CTabbedView::CTabbedView()
{
}
CTabbedView::~CTabbedView()
{
}
BOOL CTabbedView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CTabView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CTabbedView drawing
void CTabbedView::OnDraw(CDC* /*pDC*/)
{
// CTabbedViewDoc* pDoc = GetDocument();
// ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
}
/////////////////////////////////////////////////////////////////////////////
// CTabbedView printing
void CTabbedView::OnFilePrintPreview()
{
AFXPrintPreview (this);
}
BOOL CTabbedView::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CTabbedView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CTabbedView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
/////////////////////////////////////////////////////////////////////////////
// CTabbedView diagnostics
#ifdef _DEBUG
void CTabbedView::AssertValid() const
{
CTabView::AssertValid();
}
void CTabbedView::Dump(CDumpContext& dc) const
{
CTabView::Dump(dc);
}
CModeler1Doc* CTabbedView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CModeler1Doc)));
return (CModeler1Doc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CTabbedView message handlers
int CTabbedView::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CTabView::OnCreate(lpCreateStruct) == -1)
return -1;
AddView (RUNTIME_CLASS (CModeler1View), _T("Modeling"), 100);
AddView (RUNTIME_CLASS (CModeler1SourceView), _T("Comments"), 101);
//AddView (RUNTIME_CLASS (CSourceCodeView), _T("Code"), 102);
return 0;
}
BOOL CTabbedView::OnEraseBkgnd(CDC* /*pDC*/)
{
return TRUE;
}
void CTabbedView::OnActivateView(CView* view)
{
if (view->IsKindOf(RUNTIME_CLASS(CModeler1SourceView)))
{
CModeler1SourceView* pSourceView = (CModeler1SourceView*)view;
CEdit& ctrlEdit = pSourceView->GetEditCtrl();
CMainFrame* pFrame = (CMainFrame*)AfxGetMainWnd();
CElementManager* pManager = pFrame->GetManager();
if (pManager->HasSelection())
{
shared_ptr<CElement> pElement = nullptr;
pElement = pManager->m_selection.GetHead();
pManager->m_bSavingCode = true;
//ctrlEdit.SetWindowText(pElement->m_text.c_str());
ctrlEdit.SetWindowText(pElement->m_code.c_str());
pManager->m_bSavingCode = false;
}
else
{
pManager->m_bSavingCode = true;
ctrlEdit.SetWindowText(_T("No selected element!"));
pManager->m_bSavingCode = false;
}
}
}