?? exp33_1view.cpp
字號:
// Exp33_1View.cpp : implementation of the CExp33_1View class
//
#include "stdafx.h"
#include "Exp33_1.h"
#include "Exp33_1Doc.h"
#include "Exp33_1View.h"
#include "graphdlg.h"
#include "line.h"
#include "circle.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CExp33_1View
IMPLEMENT_DYNCREATE(CExp33_1View, CView)
BEGIN_MESSAGE_MAP(CExp33_1View, CView)
//{{AFX_MSG_MAP(CExp33_1View)
ON_COMMAND(ID_GRAPH, OnGraph)
//}}AFX_MSG_MAP
// 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)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CExp33_1View construction/destruction
CExp33_1View::CExp33_1View()
{
// TODO: add construction code here
}
CExp33_1View::~CExp33_1View()
{
}
BOOL CExp33_1View::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CExp33_1View drawing
void CExp33_1View::OnDraw(CDC* pDC)
{
CExp33_1Doc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
pDC->SelectStockObject(NULL_BRUSH); //選擇空畫刷,使圖形透明
POSITION pos;
CElement *elem;
pos = m_pViewList->GetHeadPosition();
while(pos!=NULL){ //畫出鏈表中所有圖形
elem = (CElement*)m_pViewList->GetAt(pos);
elem->Draw(pDC);
m_pViewList->GetNext(pos);
}
}
/////////////////////////////////////////////////////////////////////////////
// CExp33_1View printing
BOOL CExp33_1View::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CExp33_1View::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CExp33_1View::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
/////////////////////////////////////////////////////////////////////////////
// CExp33_1View diagnostics
#ifdef _DEBUG
void CExp33_1View::AssertValid() const
{
CView::AssertValid();
}
void CExp33_1View::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CExp33_1Doc* CExp33_1View::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CExp33_1Doc)));
return (CExp33_1Doc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CExp33_1View message handlers
void CExp33_1View::OnGraph()
{
// TODO: Add your command handler code here
CGraphDlg dlg;
if((dlg.DoModal())==IDOK){
m_color = RGB(dlg.m_intRed,dlg.m_intGreen,dlg.m_intBlue);
m_type = dlg.m_intType ; //設(shè)置類型
if(m_type ==0){ //構(gòu)造直線
CLine *pLine = new CLine(dlg.m_intX1,dlg.m_intY1,
dlg.m_intX2,dlg.m_intY2);
pLine->SetColor(m_color); //設(shè)置顏色
m_position = m_pViewList->AddTail(pLine); //添加至鏈表
}
else { //構(gòu)造圓
CCircle *pCircle = new CCircle(dlg.m_intX1,dlg.m_intY1,
dlg.m_intX2);
pCircle->SetColor(m_color); //設(shè)置顏色
m_position = m_pViewList->AddTail(pCircle); //添加至鏈表
}
}
Invalidate();
CExp33_1Doc* pDoc = GetDocument();
pDoc->SetModifiedFlag(); //為文檔設(shè)置修改標(biāo)志
pDoc->UpdateAllViews(this); //更新文檔的所有視圖類
}
void CExp33_1View::OnInitialUpdate()
{
CView::OnInitialUpdate();
// TODO: Add your specialized code here and/or call the base class
CExp33_1Doc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
m_pViewList = &( pDoc->m_elemList);
m_position = m_pViewList->GetHeadPosition();
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -