-
Notifications
You must be signed in to change notification settings - Fork 2
/
BCGPChartExampleView.cpp
258 lines (203 loc) · 6.39 KB
/
BCGPChartExampleView.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
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
//*******************************************************************************
// COPYRIGHT NOTES
// ---------------
// This is a sample for BCGControlBar Library Professional Edition
// Copyright (C) 1998-2014 BCGSoft Ltd.
// All rights reserved.
//
// This source code can be used, distributed or modified
// only under terms and conditions
// of the accompanying license agreement.
//*******************************************************************************
//
// BCGPChartExampleView.cpp : implementation of the CBCGPChartExampleView class
//
#include "stdafx.h"
#include "BCGPChartExample.h"
#include "MainFrm.h"
#include "BCGPChartExampleDoc.h"
#include "BCGPChartExampleView.h"
//
//#include "LogProcedure.h"
#include "Includes_app.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
//#define MAINTAINCFG_PATH _T("./Config/maintaincfg.ini")
//#define SYSTEMCFG_PATH _T("./Config/systemcfg.ini")
//#define SYSTEMCFG2_PATH _T ("./Config/systemcfg2.ini")
//#define SYSTEMCFG3_PATH _T ("./Config/systemcfg3.ini")
//#define LOG_PATH _T("./Config/logfile.ini")
/////////////////////////////////////////////////////////////////////////////
// CBCGPChartExampleView
IMPLEMENT_DYNCREATE(CBCGPChartExampleView, CBCGPFormView)
BEGIN_MESSAGE_MAP(CBCGPChartExampleView, CBCGPFormView)
//{{AFX_MSG_MAP(CBCGPChartExampleView)
ON_WM_PAINT()
//}}AFX_MSG_MAP
//ON_COMMAND(ID_FILE_PRINT, CBCGPFormView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT, CBCGPFormView::OnFilePrint)
//ON_COMMAND(ID_FILE_PRINT_PREVIEW, OnFilePrintPreview)
ON_MESSAGE(WM_INITDIALOG, HandleInitDialog)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CBCGPChartExampleView construction/destruction
CBCGPChartExampleView::CBCGPChartExampleView(UINT id)
: CBCGPFormView(id == 0 ? CBCGPChartExampleView::IDD : id)
{
EnableVisualManagerStyle();
EnableLayout();
SetWhiteBackground();
m_bIsReady = FALSE;
m_bIsDarkBackground = FALSE;
m_bIsTexturedTheme = FALSE;
m_bIsFlatTheme = FALSE;
}
CBCGPChartExampleView::~CBCGPChartExampleView()
{
}
BOOL CBCGPChartExampleView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CBCGPFormView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CBCGPChartExampleView diagnostics
#ifdef _DEBUG
void CBCGPChartExampleView::AssertValid() const
{
CBCGPFormView::AssertValid();
}
void CBCGPChartExampleView::Dump(CDumpContext& dc) const
{
CBCGPFormView::Dump(dc);
}
CBCGPChartExampleDoc* CBCGPChartExampleView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CBCGPChartExampleDoc)));
return (CBCGPChartExampleDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CBCGPChartExampleView message handlers
void CBCGPChartExampleView::OnPaint()
{
CPaintDC dc(this); // device context for painting
CRect rectTitle;
GetDlgItem(IDC_TITLE)->GetWindowRect(rectTitle);
ScreenToClient(rectTitle);
#ifdef _BCGSUITE_INC_
CFont* pOldFont = dc.SelectObject(&globalData.fontBold);
#else
CFont* pOldFont = dc.SelectObject(&globalData.fontCaption);
#endif
dc.SetTextColor(globalData.clrWindowText);
dc.SetBkMode(TRANSPARENT);
dc.DrawText(m_strTitle, rectTitle, DT_SINGLELINE | DT_END_ELLIPSIS);
dc.SelectObject(pOldFont);
}
LRESULT CBCGPChartExampleView::HandleInitDialog(WPARAM wParam, LPARAM lParam)
{
LRESULT lRes = CBCGPFormView::HandleInitDialog (wParam, lParam);
if (GetLayout() != NULL)
{
UpdateData(FALSE);
SetupLayout();
}
return lRes;
}
void CBCGPChartExampleView::OnInitialUpdate()
{
CBCGPFormView::OnInitialUpdate();
if (m_bIsReady)
{
return;
}
srand((unsigned)time(NULL));
GetParentFrame()->RecalcLayout();
if (AfxGetMainWnd() == NULL)
{
return;
}
CBCGPOutlookBarPane m_wndShortcutsPane1;
CBCGPOutlookBar m_wndShortcutsBar;
int nID = GetDlgCtrlID() - AFX_IDW_PANE_FIRST + 1;
//m_wndShortcutsBar.Gets;//GetFeatureName(nID, m_strTitle);
//m_Feature = workspace.GetFeature(nID);
CBCGPChartVisualObject* pChart = GetChart();
if (pChart != NULL)
{
pChart->ShowAxisIntervalInterlacing(BCGP_CHART_X_PRIMARY_AXIS);
}
//((CMainFrame*)AfxGetMainWnd())->GetFeatureName(nID, m_strTitle);
//m_Feature =((CMainFrame*)AfxGetMainWnd())->GetFeature(nID);
//UpdateChartColorTheme(((CMainFrame*)AfxGetMainWnd())->GetColorTheme());
}
void CBCGPChartExampleView::SetupLayout()
{
CBCGPStaticLayout* pLayout = (CBCGPStaticLayout*)GetLayout();
if (pLayout != NULL && GetCtrl() != NULL)
{
pLayout->AddAnchor(GetCtrl()->GetDlgCtrlID(), CBCGPStaticLayout::e_MoveTypeNone, CBCGPStaticLayout::e_SizeTypeBoth);
}
}
void CBCGPChartExampleView::SetDefaultLineWidth()
{
CBCGPChartVisualObject* pChart = GetChart();
if (pChart == NULL)
{
return;
}
ASSERT_VALID(pChart);
for (int i = 0; i < pChart->GetSeriesCount(); i++)
{
CBCGPChartSeries* pSeries = pChart->GetSeries(i);
ASSERT_VALID(pSeries);
BCGPChartFormatSeries style = pSeries->GetSeriesFormat();
style.SetSeriesLineWidth(theApp.GetDefaultLineWidth());
pSeries->SetSeriesFormat(style);
}
}
/////////////////////////////////////////////////////////////////////////////
// CBCGPChartExampleView printing
//打印预览,会隐藏当前页面,容易造成问题
void CBCGPChartExampleView::OnFilePrintPreview()
{
//CView* pCurView=pMainFrame->GetCurrentView();
#ifdef _BCGSUITE_INC_
AFXPrintPreview(this);
#else
BCGPPrintPreview (this);
#endif
}
BOOL CBCGPChartExampleView::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CBCGPChartExampleView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CBCGPChartExampleView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
void CBCGPChartExampleView::OnPrint(CDC* pDC, CPrintInfo* pInfo)
{
CBCGPBaseVisualCtrl* pCtrl = GetCtrl();
if (pCtrl != NULL)
{
// Since D2D has some print problems, active the GDI graphics manager:
pCtrl->SetGraphicsManager(CBCGPGraphicsManager::BCGP_GRAPHICS_MANAGER_GDI);
pCtrl->DoPrint(pDC, pInfo);
// Restore default graphics manager:
pCtrl->SetGraphicsManager(CBCGPGraphicsManager::BCGP_GRAPHICS_MANAGER_DEFAULT);
}
}
void CBCGPChartExampleView::UpdateChartColorTheme(int nTheme)
{
}