-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAI3View.cpp
159 lines (138 loc) · 3.62 KB
/
AI3View.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
// AI1View.cpp : implementation of the CAI3View class
//
#include "stdafx.h"
#include "AI3.h"
#include "AI3Doc.h"
#include "AI3View.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CAI3View
IMPLEMENT_DYNCREATE(CAI3View, CScrollView)
BEGIN_MESSAGE_MAP(CAI3View, CScrollView)
ON_COMMAND(IDM_ViewStepOnly, OnViewStepOnly)
ON_UPDATE_COMMAND_UI(IDM_ViewStepOnly, OnUpdateViewStepOnly)
ON_COMMAND(IDM_ViewTreeOnly, OnViewTreeOnly)
ON_UPDATE_COMMAND_UI(IDM_ViewTreeOnly, OnUpdateViewTreeOnly)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CAI3View construction/destruction
CAI3View::CAI3View()
{
m_bIsDispAll = true;
}
CAI3View::~CAI3View()
{
}
BOOL CAI3View::PreCreateWindow(CREATESTRUCT& cs)
{
return CScrollView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CAI3View drawing
void CAI3View::OnDraw(CDC* pDC)
{
CAI3Doc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
POSITION pos = pDoc->m_DispList.GetHeadPosition();
if(pos == NULL) return;
//显示
int DispX,DispY;
while(pos)
{
CDisplay *Item = (CDisplay *)pDoc->m_DispList.GetNext(pos);
DispY = (Item->GetCurrentG())*70+10;
if(m_bIsDispAll)
{
for(int i=0; i<3; i++)
{
DispX = (Item->GetCurrentCount())*70+10;
if(Item->GetIsAAnswer()) pDC->SetTextColor(RGB(255,0,0));
else pDC->SetTextColor(RGB(0,0,0));
for(int j=0; j<3; j++)
{
pDC->Rectangle(DispX-1,DispY-1,DispX+20,DispY+20);
DataType DataItem = Item->GetDispData(i,j);
CString DispItem;
if(DataItem != 0) DispItem.Format("%d ",DataItem);
else DispItem =" ";
pDC->TextOut(DispX, DispY, DispItem);
DispX += 20;
}
DispY += 20;
}
DispY += 10;
}
else
{
if(Item->GetIsAAnswer() == false) continue;
for(int i=0; i<3; i++)
{
DispX = 10;
pDC->SetTextColor(RGB(0,0,0));
for(int j=0; j<3; j++)
{
pDC->Rectangle(DispX-1,DispY-1,DispX+20,DispY+20);
DataType DataItem = Item->GetDispData(i,j);
CString DispItem;
if(DataItem != 0) DispItem.Format("%d ",DataItem);
else DispItem =" ";
pDC->TextOut(DispX, DispY, DispItem);
DispX += 20;
}
DispY += 20;
}
DispY += 10;
}
}
//判断是否生成滚动条
CSize sizeTotal;
sizeTotal.cx = DispX+80;
sizeTotal.cy = DispY+10;
SetScrollSizes(MM_TEXT, sizeTotal);
}
void CAI3View::OnInitialUpdate()
{
CScrollView::OnInitialUpdate();
CSize sizeTotal;
sizeTotal.cx = sizeTotal.cy = 100;
SetScrollSizes(MM_TEXT, sizeTotal);
}
/////////////////////////////////////////////////////////////////////////////
// CAI3View diagnostics
void CAI3View::AssertValid() const
{
CScrollView::AssertValid();
}
void CAI3View::Dump(CDumpContext& dc) const
{
CScrollView::Dump(dc);
}
CAI3Doc* CAI3View::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CAI3Doc)));
return (CAI3Doc*)m_pDocument;
}
/////////////////////////////////////////////////////////////////////////////
// CAI3View message handlers
void CAI3View::OnViewStepOnly()
{
this->m_bIsDispAll = FALSE;
Invalidate();
}
void CAI3View::OnUpdateViewStepOnly(CCmdUI* pCmdUI)
{
pCmdUI->SetCheck(!m_bIsDispAll);
}
void CAI3View::OnViewTreeOnly()
{
this->m_bIsDispAll = TRUE;
Invalidate();
}
void CAI3View::OnUpdateViewTreeOnly(CCmdUI* pCmdUI)
{
pCmdUI->SetCheck(m_bIsDispAll);
}