-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCumulativeFrame.cpp
More file actions
187 lines (166 loc) · 5.44 KB
/
CumulativeFrame.cpp
File metadata and controls
187 lines (166 loc) · 5.44 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
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
// CumulativeFrame.cpp : implementation file
//
#include "stdafx.h"
//#include "dibapi.h"
#include "fireplus.h"
#include "CumulativeFrame.h"
#include "CumulativePcnt.h"
#include "CumulativeBars.h"
#include <direct.h>
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
static UINT cfindicators[] =
{
ID_SEPARATOR, // status line indicator
ID_INDICATOR_XPROMPT,
ID_INDICATOR_X,
ID_INDICATOR_YPROMPT,
ID_INDICATOR_Y,
// ID_INDICATOR_CAPS,
};
extern CFireplusApp theApp;
/////////////////////////////////////////////////////////////////////////////
// CCumulativeFrame
IMPLEMENT_DYNCREATE(CCumulativeFrame, CMDIChildWnd)
CCumulativeFrame::CCumulativeFrame()
{
}
CCumulativeFrame::~CCumulativeFrame()
{
}
BEGIN_MESSAGE_MAP(CCumulativeFrame, CMDIChildWnd)
//{{AFX_MSG_MAP(CCumulativeFrame)
ON_COMMAND(ID_FILE_PRINT_PRINTGRAPH, OnFilePrintPrintgraph)
ON_COMMAND(ID_FILE_PRINT1, OnFilePrint1)
ON_COMMAND(ID_FILE_SAVE_BARGRAPH, OnFileSaveBargraph)
ON_COMMAND(ID_FILE_SAVE_PERCENTILESGRAPH, OnFileSavePercentilesgraph)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CCumulativeFrame message handlers
BOOL CCumulativeFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
{
if (!m_wndStatusBar.Create(this) ||
!m_wndStatusBar.SetIndicators(cfindicators,
sizeof(cfindicators)/sizeof(UINT)))
{
TRACE0("Failed to create status bar\n");
return -1; // fail to create
}
//CONFIGURE STATUS BAR
UINT id, style;
int wid;
m_wndStatusBar.GetPaneInfo(1, id, style , wid);
m_wndStatusBar.SetPaneInfo(1, ID_INDICATOR_XPROMPT, SBPS_NOBORDERS , wid);
m_wndStatusBar.GetPaneInfo(2, id, style , wid);
m_wndStatusBar.SetPaneInfo(2, ID_INDICATOR_X, SBPS_NORMAL , wid + wid);
m_wndStatusBar.GetPaneInfo(3, id, style , wid);
m_wndStatusBar.SetPaneInfo(3, ID_INDICATOR_YPROMPT, SBPS_NOBORDERS , wid);
m_wndStatusBar.GetPaneInfo(4, id, style , wid);
m_wndStatusBar.SetPaneInfo(4, ID_INDICATOR_Y, SBPS_NORMAL , wid + wid);
m_wndStatusBar.SetPaneText(0, "Left click to retrieve values");
m_wndStatusBar.SetPaneText(2, "");
m_wndStatusBar.SetPaneText(4, "");
if (!m_wndSplitter.CreateStatic(this, 1, 2))
{
TRACE0("Failed to CreateStaticSplitter\n");
return FALSE;
}
//LPRECT rect;
//GetClientRect(rect);
//int wid = (rect->right - rect->left) / 3 * 2;
// add the first splitter pane - the default view in column 0
if (!m_wndSplitter.CreateView(0, 0,
pContext->m_pNewViewClass, CSize(300, 50), pContext))
{
TRACE0("Failed to create first pane\n");
return FALSE;
}
// add the second splitter pane - a graph view in column 1
if (!m_wndSplitter.CreateView(0, 1,
RUNTIME_CLASS(CCumulativePcnt), CSize(0, 0), pContext))
{
TRACE0("Failed to create second pane\n");
return FALSE;
}
return TRUE;//CMDIChildWnd::OnCreateClient(lpcs, pContext);
}
void CCumulativeFrame::MaximizePane(CView * view)
{
int r, c, cxCur0, cxMin0, cxCur1, cxMin1;
if(m_wndSplitter.IsChildPane((CWnd *)view, &r, &c)) //safety
{
m_wndSplitter.GetColumnInfo(0, cxCur0, cxMin0);
m_wndSplitter.GetColumnInfo(1, cxCur1, cxMin1);
m_wndSplitter.SetColumnInfo((c == 0) ? 0 : 1, cxCur1 + cxCur0 - 4, cxMin0);
m_wndSplitter.SetColumnInfo((c == 0) ? 1 : 0, 4, cxMin0);
m_wndSplitter.RecalcLayout();
}
}
void CCumulativeFrame::OnFilePrintPrintgraph()
{
// TODO: Add your command handler code here
((CCumulativePcnt *)m_wndSplitter.GetPane(0, 1))->PrintGraph();
}
void CCumulativeFrame::OnFilePrint1()
{
// TODO: Add your command handler code here
((CCumulativeBars *)m_wndSplitter.GetPane(0, 0))->PrintGraph();
}
void CCumulativeFrame::OnFileSaveBargraph()
{
chdir(theApp.userDir);
CFileDialog fd(false, theApp.GetGraphicsExt(), NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
theApp.GetGraphicsFileStr(), this);
if(fd.DoModal() == IDOK)
{
CDC *whdc = GetDC();
CDC memhdc;
memhdc.CreateCompatibleDC(NULL);
HBITMAP picture = CreateCompatibleBitmap(whdc->m_hDC, 640, 480);
HGDIOBJ Old = SelectObject(memhdc.m_hDC, picture);
//CRect bnd(0, 0, pWidth.GetValueInteger(), pHeight.GetValueInteger());
CRect rect(0, 0, 640, 480);
((CCumulativeBars *)m_wndSplitter.GetPane(0, 0))->DrawToDCRegion(&memhdc, rect);
char fName[256];
strcpy_s(fName, fd.GetPathName());
SaveBitmapFile(memhdc.m_hDC, picture, fName);
SelectObject(memhdc.m_hDC, Old);
ReleaseDC(whdc);
memhdc.DeleteDC();
DeleteObject(picture);
theApp.SetUserDir(fd.GetPathName());
theApp.SetGraphicsExt(fd.GetFileExt());
}
chdir(theApp.dbDir);//.workDir);
}
void CCumulativeFrame::OnFileSavePercentilesgraph()
{
chdir(theApp.userDir);
CFileDialog fd(false, theApp.GetGraphicsExt(), NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
theApp.GetGraphicsFileStr(), this);
if(fd.DoModal() == IDOK)
{
CDC *whdc = GetDC();
CDC memhdc;
memhdc.CreateCompatibleDC(NULL);
HBITMAP picture = CreateCompatibleBitmap(whdc->m_hDC, 640, 480);
HGDIOBJ Old = SelectObject(memhdc.m_hDC, picture);
//CRect bnd(0, 0, pWidth.GetValueInteger(), pHeight.GetValueInteger());
CRect rect(0, 0, 640, 480);
((CCumulativePcnt *)m_wndSplitter.GetPane(0, 0))->DrawToDCRegion(&memhdc, rect);
char fName[256];
strcpy_s(fName, fd.GetPathName());
SaveBitmapFile(memhdc.m_hDC, picture, fName);
SelectObject(memhdc.m_hDC, Old);
ReleaseDC(whdc);
memhdc.DeleteDC();
DeleteObject(picture);
theApp.SetUserDir(fd.GetPathName());
theApp.SetGraphicsExt(fd.GetFileExt());
}
chdir(theApp.dbDir);//theApp.workDir);
}