📄 bysjview.cpp
字号:
// bysjView.cpp : implementation of the CBysjView class
//
#include "stdafx.h"
#include "bysj.h"
#include "bysjDoc.h"
#include "CntrItem.h"
#include "bysjView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CBysjView
IMPLEMENT_DYNCREATE(CBysjView, CScrollView)
BEGIN_MESSAGE_MAP(CBysjView, CScrollView)
//{{AFX_MSG_MAP(CBysjView)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code!
ON_WM_DESTROY()
ON_WM_SETFOCUS()
ON_WM_SIZE()
ON_COMMAND(ID_OLE_INSERT_NEW, OnInsertObject)
ON_COMMAND(ID_CANCEL_EDIT_CNTR, OnCancelEditCntr)
//}}AFX_MSG_MAP
// Standard printing commands
ON_COMMAND(ID_FILE_PRINT, CScrollView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT, CScrollView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, CScrollView::OnFilePrintPreview)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CBysjView construction/destruction
CBysjView::CBysjView()
{
m_pSelection = NULL;
// TODO: add construction code here
}
CBysjView::~CBysjView()
{
}
BOOL CBysjView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CScrollView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CBysjView drawing
void CBysjView::OnDraw(CDC* pDC)
{
CBysjDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
pDC->MoveTo(40,40);
pDC->LineTo(110,40);
pDC->MoveTo(40,90);
pDC->LineTo(110,90);
pDC->MoveTo(40,2000);
pDC->LineTo(110,2000);
pDC->MoveTo(40,40);
pDC->LineTo(40,2000);
pDC->MoveTo(110,40);
pDC->LineTo(110,2000);
pDC->MoveTo(110,40);
pDC->LineTo(710,40);
pDC->MoveTo(110,90);
pDC->LineTo(710,90);
pDC->MoveTo(310,40);
pDC->LineTo(310,2000);
pDC->MoveTo(510,40);
pDC->LineTo(510,2000);
pDC->MoveTo(710,40);
pDC->LineTo(710,2000);
for(int l=0;l<30;l++)
{
pDC->MoveTo(110+l*20,90);
pDC->LineTo(110+l*20,2000);
}
pDC->TextOut(400,60,"AC");
pDC->TextOut(200,60,"YXZ");
pDC->TextOut(50,60,"DEPTH");
pDC->TextOut(560,60,"深度校正");
for(int r=0;r<125;r++)
{
pDC->MoveTo(40,90+r*16);
pDC->LineTo(710,90+r*16);
}
pDC->TextOut(50,90,"1280");
pDC->TextOut(50,410,"1300");
pDC->TextOut(50,890,"1330");
pDC->TextOut(50,1690,"1380");
pDC->TextOut(50,2490,"1430");
if(pDoc->m_Data == TRUE)
pDoc->draw(pDC);
// TODO: add draw code for native data here
// TODO: also draw all OLE items in the document
// Draw the selection at an arbitrary position. This code should be
// removed once your real drawing code is implemented. This position
// corresponds exactly to the rectangle returned by CBysjCntrItem,
// to give the effect of in-place editing.
// TODO: remove this code when final draw code is complete.
if (m_pSelection == NULL)
{
POSITION pos = pDoc->GetStartPosition();
m_pSelection = (CBysjCntrItem*)pDoc->GetNextClientItem(pos);
}
if (m_pSelection != NULL)
m_pSelection->Draw(pDC, CRect(10, 10, 210, 210));
}
void CBysjView::OnInitialUpdate()
{
CScrollView::OnInitialUpdate();
// TODO: remove this code when final selection model code is written
m_pSelection = NULL; // initialize selection
CSize sizeTotal;
// TODO: calculate the total size of this view
sizeTotal.cx = 1000;
sizeTotal.cy = 2000;
SetScrollSizes(MM_TEXT, sizeTotal);
}
/////////////////////////////////////////////////////////////////////////////
// CBysjView printing
BOOL CBysjView::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CBysjView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CBysjView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
void CBysjView::OnDestroy()
{
// Deactivate the item on destruction; this is important
// when a splitter view is being used.
CScrollView::OnDestroy();
COleClientItem* pActiveItem = GetDocument()->GetInPlaceActiveItem(this);
if (pActiveItem != NULL && pActiveItem->GetActiveView() == this)
{
pActiveItem->Deactivate();
ASSERT(GetDocument()->GetInPlaceActiveItem(this) == NULL);
}
}
/////////////////////////////////////////////////////////////////////////////
// OLE Client support and commands
BOOL CBysjView::IsSelected(const CObject* pDocItem) const
{
// The implementation below is adequate if your selection consists of
// only CBysjCntrItem objects. To handle different selection
// mechanisms, the implementation here should be replaced.
// TODO: implement this function that tests for a selected OLE client item
return pDocItem == m_pSelection;
}
void CBysjView::OnInsertObject()
{
// Invoke the standard Insert Object dialog box to obtain information
// for new CBysjCntrItem object.
COleInsertDialog dlg;
if (dlg.DoModal() != IDOK)
return;
BeginWaitCursor();
CBysjCntrItem* pItem = NULL;
TRY
{
// Create new item connected to this document.
CBysjDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
pItem = new CBysjCntrItem(pDoc);
ASSERT_VALID(pItem);
// Initialize the item from the dialog data.
if (!dlg.CreateItem(pItem))
AfxThrowMemoryException(); // any exception will do
ASSERT_VALID(pItem);
if (dlg.GetSelectionType() == COleInsertDialog::createNewItem)
pItem->DoVerb(OLEIVERB_SHOW, this);
ASSERT_VALID(pItem);
// As an arbitrary user interface design, this sets the selection
// to the last item inserted.
// TODO: reimplement selection as appropriate for your application
m_pSelection = pItem; // set selection to last inserted item
pDoc->UpdateAllViews(NULL);
}
CATCH(CException, e)
{
if (pItem != NULL)
{
ASSERT_VALID(pItem);
pItem->Delete();
}
AfxMessageBox(IDP_FAILED_TO_CREATE);
}
END_CATCH
EndWaitCursor();
}
// The following command handler provides the standard keyboard
// user interface to cancel an in-place editing session. Here,
// the container (not the server) causes the deactivation.
void CBysjView::OnCancelEditCntr()
{
// Close any in-place active item on this view.
COleClientItem* pActiveItem = GetDocument()->GetInPlaceActiveItem(this);
if (pActiveItem != NULL)
{
pActiveItem->Close();
}
ASSERT(GetDocument()->GetInPlaceActiveItem(this) == NULL);
}
// Special handling of OnSetFocus and OnSize are required for a container
// when an object is being edited in-place.
void CBysjView::OnSetFocus(CWnd* pOldWnd)
{
COleClientItem* pActiveItem = GetDocument()->GetInPlaceActiveItem(this);
if (pActiveItem != NULL &&
pActiveItem->GetItemState() == COleClientItem::activeUIState)
{
// need to set focus to this item if it is in the same view
CWnd* pWnd = pActiveItem->GetInPlaceWindow();
if (pWnd != NULL)
{
pWnd->SetFocus(); // don't call the base class
return;
}
}
CScrollView::OnSetFocus(pOldWnd);
}
void CBysjView::OnSize(UINT nType, int cx, int cy)
{
CScrollView::OnSize(nType, cx, cy);
COleClientItem* pActiveItem = GetDocument()->GetInPlaceActiveItem(this);
if (pActiveItem != NULL)
pActiveItem->SetItemRects();
}
/////////////////////////////////////////////////////////////////////////////
// CBysjView diagnostics
#ifdef _DEBUG
void CBysjView::AssertValid() const
{
CScrollView::AssertValid();
}
void CBysjView::Dump(CDumpContext& dc) const
{
CScrollView::Dump(dc);
}
CBysjDoc* CBysjView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CBysjDoc)));
return (CBysjDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CBysjView message handlers
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -