aboutsummaryrefslogtreecommitdiff
path: root/Freeview.cpp
blob: 1a0c3c5ed9092616d7d434f9917f4a8236375f30 (plain) (blame)
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

#include "stdafx.h"

IMPLEMENT_DYNCREATE(CFreeView, CWnd)

CFreeView::CFreeView()
{
	m_document = NULL;
}

CFreeView::~CFreeView()
{
	if (m_document != NULL)
		m_document->RemoveView(this);
}

BEGIN_MESSAGE_MAP(CFreeView, CWnd)
	//{{AFX_MSG_MAP(CFreeView)
	ON_WM_SIZE()
	ON_WM_PAINT()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

BOOL CFreeView::Create(CWnd *parent, BOOL show)
{
	CRect rect;

	if (parent != NULL)
		parent->GetClientRect(&rect);
	else {
		rect.left = 0, rect.right = 16;
		rect.top = 0, rect.bottom = 16;
	}

	if (!CWnd::Create(NULL, NULL, WS_CHILD,
		rect, parent, 0)) return(FALSE);
	if (show) {
		ShowWindow(SW_SHOWNORMAL);
		UpdateWindow();
	}

	return(TRUE);
}

void CFreeView::SetDocument(CFreeDoc *document)
{
	if (m_document != NULL) m_document->RemoveView(this);
	if (document != NULL) document->AddView(this);
}

CFreeDoc *CFreeView::GetDocument(void)
{
	return(m_document);
}

void CFreeView::OnSize(UINT nType, int cx, int cy)
{
	CWnd::OnSize(nType, cx, cy);
	m_width = cx, m_height = cy;
}

void CFreeView::OnDraw(CDC* pDC)
{
}

void CFreeView::OnUpdate(CFreeDoc *doc)
{
}

void CFreeView::OnPaint()
{
	CPaintDC dc(this);
	OnDraw(&dc);
}