ellipse (mfc, View.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
// WinLab(01)View.cpp : implementation of the CWinLab01View class
//
#include "stdafx.h"
#include "afxwin.h"
// SHARED_HANDLERS can be defined in an ATL project implementing preview, thumbnail
// and search filter handlers and allows sharing of document code with that project.
#ifndef SHARED_HANDLERS
#include "WinLab(01).h"
#endif
#include "WinLab(01)Doc.h"
#include "WinLab(01)View.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
#include "Objects.h"
#include "SizeDialiog.h"
Objects ob;
// CWinLab01View
IMPLEMENT_DYNCREATE(CWinLab01View, CView)
BEGIN_MESSAGE_MAP(CWinLab01View, CView)
// Standard printing commands
ON_COMMAND(ID_FILE_PRINT, &CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT, &CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, &CView::OnFilePrintPreview)
ON_WM_LBUTTONDOWN()
ON_COMMAND(ID_CUSTOM_SIZE, &CWinLab01View::OnCustomSize)
ON_COMMAND(ID_CUSTOM_COLOR, &CWinLab01View::OnCustomColor)
ON_COMMAND(ID_FILE_OPEN, &CWinLab01View::OnFileOpen)
END_MESSAGE_MAP()
// CWinLab01View construction/destruction
CWinLab01View::CWinLab01View()
{
// TODO: add construction code here
}
CWinLab01View::~CWinLab01View()
{
}
BOOL CWinLab01View::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CView::PreCreateWindow(cs);
}
// CWinLab01View drawing
void CWinLab01View::OnDraw(CDC* pDC/*pDC*/)
{
CWinLab01Doc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
ob.DrawDraft(pDC);
if (!pDoc)
return;
// TODO: add draw code for native data here
}
// CWinLab01View printing
BOOL CWinLab01View::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CWinLab01View::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CWinLab01View::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
// CWinLab01View diagnostics
#ifdef _DEBUG
void CWinLab01View::AssertValid() const
{
CView::AssertValid();
}
void CWinLab01View::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CWinLab01Doc* CWinLab01View::GetDocument() const // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CWinLab01Doc)));
return (CWinLab01Doc*)m_pDocument;
}
#endif //_DEBUG
// CWinLab01View message handlers
void CWinLab01View::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
ob.m_xcenter[ob.amount] = point.x;
ob.m_ycenter[ob.amount] = point.y;
ob.amount++;
Invalidate();
if(ob.amount == MAX) { AfxMessageBox(_T("Massive is Full")); exit(0);}
}
void CWinLab01View::OnCustomSize()
{
SizeDialiog sd;
sd.DoModal();
for(int i(ob.amount); i != MAX; ++i)
{
ob.m_width[i] = sd.width/2;
ob.m_height[i] = sd.height/2;
}
// TODO: Add your command handler code here
}
void CWinLab01View::OnCustomColor()
{
CColorDialog cc;
if (cc.DoModal()==IDOK)
for(int i(ob.amount); i != MAX; ++i)
ob.Color[i] = cc.GetColor();
// TODO: Add your command handler code here
}
void CWinLab01View::OnFileOpen()
{
CFileDialog CR(TRUE);
CFile CFileRead;
CR.DoModal();
CFileRead.Open(CR.GetPathName(), CFile::modeReadWrite);
CArchive Arch(&CFileRead, CArchive::load);
ob.Serialize(Arch);
Arch.Close();
CFileRead.Close();
Invalidate();
// TODO: Add your command handler code here
}