-
Notifications
You must be signed in to change notification settings - Fork 2
/
ColorEyeIView.cpp
238 lines (190 loc) · 7.28 KB
/
ColorEyeIView.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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
// ColorEyeIView.cpp : implementation of the CColorEyeIView class
//
#include "stdafx.h"
#include "ColorEyeI.h"
#include "ColorEyeIDoc.h"
#include "ColorEyeIView.h"
#include "MainFrm.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CColorEyeIView
IMPLEMENT_DYNCREATE(CColorEyeIView, CScrollView)
BEGIN_MESSAGE_MAP(CColorEyeIView, CScrollView)
//{{AFX_MSG_MAP(CColorEyeIView)
ON_WM_VSCROLL()
ON_WM_MOUSEWHEEL()
ON_WM_LBUTTONUP()
ON_WM_MOUSEMOVE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CColorEyeIView construction/destruction
CColorEyeIView::CColorEyeIView(){}
CColorEyeIView::~CColorEyeIView(){}
BOOL CColorEyeIView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CScrollView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CColorEyeIView drawing
void CColorEyeIView::OnDraw(CDC* pDC)
{
CColorEyeIDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
int nDC = pDC->SaveDC();
const UINT TextHight(16);
CFont afont;
afont.CreateFont(TextHight, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, FF_MODERN, "Century Gothic");
pDC->SelectObject(&afont);
CSize szAroundSpace(2, 2); //視窗的留白
CPoint ptOrig(0, 0); //視窗的原點(左上角)
CPoint ptFix (0, 0);
ptOrig = ptOrig + szAroundSpace;
ptFix.x = ptFix.x + szAroundSpace.cx;
ptFix.y = ptFix.y + szAroundSpace.cy;
//表格的部份
//設計一個table class用類似HTML的語法來管理表格
//視窗左半邊,導覽區
ptFix = GetDeviceScrollPosition();
CPoint ptTemp = ptFix;
int line(0);//18*7
// pDC->TextOut(ptTemp.x, ptTemp.y, "Panel ID"); pDC->TextOut(ptTemp.x+(TextHight*9), ptTemp.y, pDoc->GetPnlID() ); line++; ptTemp.y = TextHight*(line);
// pDC->TextOut(ptTemp.x, ptTemp.y, "Measurement device"); pDC->TextOut(ptTemp.x+(TextHight*9), ptTemp.y, pDoc->GetMsrDvc() ); line++; ptTemp.y = TextHight*(line);
// pDC->TextOut(ptTemp.x, ptTemp.y, "Probe"); pDC->TextOut(ptTemp.x+(TextHight*9), ptTemp.y, pDoc->GetPrb() ); line++; ptTemp.y = TextHight*(line);
// pDC->TextOut(ptTemp.x, ptTemp.y, "Channel"); pDC->TextOut(ptTemp.x+(TextHight*9), ptTemp.y, pDoc->GetCHID() ); line++; ptTemp.y = TextHight*(line);
// pDC->TextOut(ptTemp.x, ptTemp.y, "Inch"); pDC->TextOut(ptTemp.x+(TextHight*9), ptTemp.y, pDoc->GetInch() ); line++; ptTemp.y = TextHight*(line);
pDC->TextOut(ptTemp.x, ptTemp.y, "Panel ID"); pDC->TextOut(ptTemp.x+(TextHight*9), ptTemp.y, pDoc->GetFileHead().oPnlID() ); line++; ptTemp.y = TextHight*(line);
pDC->TextOut(ptTemp.x, ptTemp.y, "Measurement device"); pDC->TextOut(ptTemp.x+(TextHight*9), ptTemp.y, pDoc->GetFileHead().oMsrDvc() ); line++; ptTemp.y = TextHight*(line);
pDC->TextOut(ptTemp.x, ptTemp.y, "Probe"); pDC->TextOut(ptTemp.x+(TextHight*9), ptTemp.y, pDoc->GetFileHead().oPrb() ); line++; ptTemp.y = TextHight*(line);
pDC->TextOut(ptTemp.x, ptTemp.y, "Channel"); pDC->TextOut(ptTemp.x+(TextHight*9), ptTemp.y, pDoc->GetFileHead().oCHID() ); line++; ptTemp.y = TextHight*(line);
pDC->TextOut(ptTemp.x, ptTemp.y, "Inch"); pDC->TextOut(ptTemp.x+(TextHight*9), ptTemp.y, pDoc->GetFileHead().oInch() ); line++; ptTemp.y = TextHight*(line);
//自訂字型
CString str;
int maxXview(0),
maxYview(0);
DNA showDNA(pDoc->GetDocDNA());
if (!showDNA.Size())
{
str.Format("(無量測紀錄)");
pDC->TextOut(ptTemp.x, ptTemp.y, str.GetBuffer(0));
}
else
{
for ( std::vector<Nucleotide>::iterator indexItor = showDNA.Begin(); indexItor != showDNA.End(); ++indexItor)
{
str.Format("%s", indexItor->ShowMe());
pDC->TextOut(ptTemp.x, ptTemp.y, str.GetBuffer(0));
//set position point
line++;
ptTemp.y = TextHight*(line);
//set max X veiw
if (maxXview < str.GetLength()*5.5)
maxXview = (int)((float)str.GetLength()*5.5); //介於5~6之間
//set max Y view
maxYview = ptTemp.y;
}
}
//視窗右半邊(主要資料檢視區)
int maxX_LeftView(maxXview);
ptTemp.x = 291;
ptTemp.y = ptOrig.y;
line = 1;
RNA showRNA(pDoc->GetDocRNA());
if (showRNA.IsEmpty())
{
str.Format("(無量測資料)");
pDC->TextOut(ptTemp.x, ptTemp.y, str.GetBuffer(0));
}
else
{
for ( std::vector<Cartridge2>::iterator dataItor = showRNA.Begin(); dataItor != showRNA.End(); ++dataItor)
{
str.Format("%s %s", dataItor->GetDescrip(), dataItor->GetBullet().ShowDataReport());
pDC->TextOut(ptTemp.x, ptTemp.y, str.GetBuffer(0));
maxYview = ptTemp.y;
if (maxXview < str.GetLength()*5.5)
maxXview = (int)((float)str.GetLength()*5.5); //介於5~6之間
ptTemp.y = TextHight*(line);
line++;
}
}
maxXview += maxX_LeftView;
pDC->RestoreDC( nDC );
//設定高度
CSize sizeTotal;
// TODO: calculate the total size of this view
sizeTotal.cx = maxXview;
sizeTotal.cy = maxYview;
SetScrollSizes(MM_TEXT, sizeTotal);
}
void CColorEyeIView::OnInitialUpdate()
{
CScrollView::OnInitialUpdate();
CSize sizeTotal;
// TODO: calculate the total size of this view
sizeTotal.cx = GetDeviceScrollPosition().x;
sizeTotal.cy = GetDeviceScrollPosition().y;
SetScrollSizes(MM_TEXT, sizeTotal);
}
/////////////////////////////////////////////////////////////////////////////
// CColorEyeIView diagnostics
#ifdef _DEBUG
void CColorEyeIView::AssertValid() const
{
CScrollView::AssertValid();
}
void CColorEyeIView::Dump(CDumpContext& dc) const
{
CScrollView::Dump(dc);
}
CColorEyeIDoc* CColorEyeIView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CColorEyeIDoc)));
return (CColorEyeIDoc*)m_pDocument;
}
#endif
/////////////////////////////////////////////////////////////////////////////
// CColorEyeIView message handlers
void CColorEyeIView::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
// TODO: Add your message handler code here and/or call default
// keepSc();
CScrollView::OnVScroll(nSBCode, nPos, pScrollBar);
}
BOOL CColorEyeIView::OnMouseWheel(UINT nFlags, short zDelta, CPoint pt)
{
// TODO: Add your message handler code here and/or call default
// keepSc();
return CScrollView::OnMouseWheel(nFlags, zDelta, pt);
}
BOOL CColorEyeIView::PreTranslateMessage(MSG* pMsg)
{
// TODO: Add your specialized code here and/or call the base class
CMainFrame* pMainFrm = dynamic_cast<CMainFrame*>(AfxGetMainWnd());
ASSERT_VALID(pMainFrm);
CColorEyeIDoc* pDoc = dynamic_cast<CColorEyeIDoc*>(pMainFrm->GetActiveDocument());
ASSERT_VALID(pDoc);
if (pMsg->message == WM_KEYDOWN)
{
switch(pMsg->wParam)
{
// case VK_SPACE: break;
// case VK_UP: break;
// case VK_DOWN: break;
// case VK_RIGHT: break;
// case VK_LEFT: break;
// case VK_RETURN: break;
// case VK_ESCAPE: break;
case VK_F5: pDoc->UpdateAllViews(NULL); break;
}
return TRUE;
}
return CScrollView::PreTranslateMessage(pMsg);
}