Repository navigation
Expand file tree
/
Copy pathGridCtrl.cpp
More file actions
executable file
·104 lines (88 loc) · 2.11 KB
/
Copy pathGridCtrl.cpp
File metadata and controls
executable file
·104 lines (88 loc) · 2.11 KB
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
// GridCtrl.cpp: implementation of the CGridCtrl class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "HDFPlugin.h"
#include "GridCtrl.h"
#include "TableView.h"
#include "HdfObjCompoundDS.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CGridCtrl::CGridCtrl()
{
m_pDataset = NULL;
}
CGridCtrl::~CGridCtrl()
{
}
void CGridCtrl::OnSetup()
{
if (!m_pDataset)
return;
Invalidate(); // erase previous display
unsigned long* count = m_pDataset->GetCount();
int rows=1, cols=1;
if (m_pDataset->GetType() == CHObject::HDF_DATASET_COMPOUND)
{
rows = ((CCompoundDS*)m_pDataset)->GetRecordSize();
cols = ((CCompoundDS*)m_pDataset)->GetMemberSize();
} else
{
rows= m_pDataset->GetHeight();
cols= m_pDataset->GetWidth();
}
SetDefColWidth(COLUMN_WIDTH);
SetNumberRows(rows);
SetNumberCols(cols);
CUGCell cell;
// set the header cell
COLORREF oldColor = cell.GetBackColor();
GetCell(-1,-1,&cell);
cell.SetBackColor(RGB(250, 230, 10));
SetCell(-1,-1,&cell);
cell.SetBackColor(oldColor);
//set row header
GetCell(0,1,&cell);
CString strBuf;
for (int i = 0; i < rows; i++)
{
strBuf.Format("%d", i+1);
cell.SetText(strBuf);
SetCell(-1,i,&cell);
}
//set col header
if (m_pDataset->GetType() == CHObject::HDF_DATASET_COMPOUND)
{
CCompoundDS* pDataset = (CCompoundDS*)m_pDataset;
for (i = 0; i < cols; i++)
{
//strcpy(strBuf, pDataset->GetMemberName(i));
cell.SetText(pDataset->GetMemberName(i));
SetCell(i,-1,&cell);
}
}
else
{
for (i = 0; i < cols; i++)
{
strBuf.Format("%d", i+1);
cell.SetText(strBuf);
SetCell(i,-1,&cell);
}
}
// set data values
for (i = 0; i < rows; i++)
{
for (int j = 0; j < cols; j++)
{
cell.SetText(m_pDataset->ValueToStr(i, j, strBuf));
SetCell(j,i,&cell);
}
}
}