GraphView.cpp
上传用户:zhanglf88
上传日期:2013-11-19
资源大小:6036k
文件大小:20k
源码类别:

金融证券系统

开发平台:

Visual C++

  1. // GraphView.cpp : implementation of the CGraphView class
  2. //
  3. #include "stdafx.h"
  4. #include "../StaticDoc.h"
  5. #include "GraphView.h"
  6. #ifdef _DEBUG
  7. #define new DEBUG_NEW
  8. #undef THIS_FILE
  9. static char THIS_FILE[] = __FILE__;
  10. #endif
  11. /////////////////////////////////////////////////////////////////////////////
  12. // CGraphView
  13. #define IDC_GRAPHVIEW_REPORTTAB 200
  14. #define GV_REPORTTAB_PARAM 0 // 参数
  15. #define GV_REPORTTAB_COST 1 // 成本
  16. #define GV_REPORTTAB_FLAME 2 // 火焰山
  17. #define GV_REPORTTAB_ACTIVITY 3 // 活跃度
  18. IMPLEMENT_DYNCREATE(CGraphView, CView)
  19. BEGIN_MESSAGE_MAP(CGraphView, CView)
  20. //{{AFX_MSG_MAP(CGraphView)
  21. ON_WM_CREATE()
  22. ON_WM_WINDOWPOSCHANGED()
  23. ON_WM_DESTROY()
  24. ON_WM_ERASEBKGND()
  25. ON_WM_LBUTTONDOWN()
  26. ON_WM_LBUTTONUP()
  27. ON_WM_MOUSEMOVE()
  28. ON_WM_LBUTTONDBLCLK()
  29. ON_WM_KEYDOWN()
  30. ON_COMMAND(ID_VIEW_PDAY, OnViewPday)
  31. ON_COMMAND(ID_VIEW_PWEEK, OnViewPweek)
  32. ON_COMMAND(ID_VIEW_PMONTH, OnViewPmonth)
  33. ON_COMMAND(ID_VIEW_PMIN5, OnViewPmin5)
  34. ON_COMMAND(ID_VIEW_PMIN15, OnViewPmin15)
  35. ON_COMMAND(ID_VIEW_PMIN30, OnViewPmin30)
  36. ON_COMMAND(ID_VIEW_PMIN60, OnViewPmin60)
  37. ON_COMMAND(ID_VIEW_LEFT, OnViewLeft)
  38. ON_COMMAND(ID_VIEW_RIGHT, OnViewRight)
  39. ON_COMMAND(ID_VIEW_PAGELEFT, OnViewPageleft)
  40. ON_COMMAND(ID_VIEW_PAGERIGHT, OnViewPageright)
  41. ON_COMMAND(ID_VIEW_HOME, OnViewHome)
  42. ON_COMMAND(ID_VIEW_END, OnViewEnd)
  43. ON_COMMAND(ID_VIEW_ZOOMIN, OnViewZoomin)
  44. ON_COMMAND(ID_VIEW_ZOOMOUT, OnViewZoomout)
  45. ON_COMMAND(ID_VIEW_PREV, OnViewPrev)
  46. ON_COMMAND(ID_VIEW_NEXT, OnViewNext)
  47. ON_COMMAND(ID_VIEW_INSERT, OnViewInsert)
  48. ON_COMMAND(ID_VIEW_NORESUMEDR, OnViewNoresumedr)
  49. ON_COMMAND(ID_VIEW_RESUMEDRUP, OnViewResumedrup)
  50. ON_COMMAND(ID_VIEW_RESUMEDRDOWN, OnViewResumedrdown)
  51. ON_COMMAND(ID_VIEW_MAINDATACLOSE, OnViewMaindataclose)
  52. ON_COMMAND(ID_VIEW_MAINDATAOPEN, OnViewMaindataopen)
  53. ON_COMMAND(ID_VIEW_MAINDATAAVERAGE, OnViewMaindataaverage)
  54. ON_COMMAND(ID_VIEW_KLINECANDLE, OnViewKlinecandle)
  55. ON_COMMAND(ID_VIEW_KLINEAMERICA, OnViewKlineamerica)
  56. ON_COMMAND(ID_VIEW_KLINETOWER, OnViewKlinetower)
  57. ON_UPDATE_COMMAND_UI(ID_VIEW_PDAY, OnUpdateViewPday)
  58. ON_UPDATE_COMMAND_UI(ID_VIEW_PWEEK, OnUpdateViewPweek)
  59. ON_UPDATE_COMMAND_UI(ID_VIEW_PMONTH, OnUpdateViewPmonth)
  60. ON_UPDATE_COMMAND_UI(ID_VIEW_PMIN5, OnUpdateViewPmin5)
  61. ON_UPDATE_COMMAND_UI(ID_VIEW_PMIN15, OnUpdateViewPmin15)
  62. ON_UPDATE_COMMAND_UI(ID_VIEW_PMIN30, OnUpdateViewPmin30)
  63. ON_UPDATE_COMMAND_UI(ID_VIEW_PMIN60, OnUpdateViewPmin60)
  64. ON_UPDATE_COMMAND_UI(ID_VIEW_NORESUMEDR, OnUpdateViewNoresumedr)
  65. ON_UPDATE_COMMAND_UI(ID_VIEW_RESUMEDRUP, OnUpdateViewResumedrup)
  66. ON_UPDATE_COMMAND_UI(ID_VIEW_RESUMEDRDOWN, OnUpdateViewResumedrdown)
  67. ON_UPDATE_COMMAND_UI(ID_VIEW_MAINDATACLOSE, OnUpdateViewMaindataclose)
  68. ON_UPDATE_COMMAND_UI(ID_VIEW_MAINDATAOPEN, OnUpdateViewMaindataopen)
  69. ON_UPDATE_COMMAND_UI(ID_VIEW_MAINDATAAVERAGE, OnUpdateViewMaindataaverage)
  70. ON_UPDATE_COMMAND_UI(ID_VIEW_KLINECANDLE, OnUpdateViewKlinecandle)
  71. ON_UPDATE_COMMAND_UI(ID_VIEW_KLINEAMERICA, OnUpdateViewKlineamerica)
  72. ON_UPDATE_COMMAND_UI(ID_VIEW_KLINETOWER, OnUpdateViewKlinetower)
  73. ON_NOTIFY(TCN_SELCHANGE, IDC_GRAPHVIEW_REPORTTAB, OnSelchangeReporttab)
  74. ON_COMMAND(ID_VIEW_HIDETHISTECH, OnViewHidethistech)
  75. ON_UPDATE_COMMAND_UI(ID_VIEW_HIDETHISTECH, OnUpdateViewHidethistech)
  76. ON_COMMAND(ID_VIEW_THISTECHPARAM, OnViewThistechparam)
  77. ON_UPDATE_COMMAND_UI(ID_VIEW_THISTECHPARAM, OnUpdateViewThistechparam)
  78. //}}AFX_MSG_MAP
  79. // Standard printing commands
  80. ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)
  81. ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)
  82. ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
  83. ON_COMMAND_RANGE(ID_VIEW_TECH_START, ID_VIEW_TECH_END, OnViewTechRange)
  84. ON_UPDATE_COMMAND_UI_RANGE(ID_VIEW_TECH_START, ID_VIEW_TECH_END, OnUpdateViewTechRange)
  85. ON_MESSAGE(WM_USER_GETVIEWTITLE, OnGetViewTitle)
  86. ON_MESSAGE(WM_USER_GETVIEWCMDID, OnGetViewCmdid)
  87. ON_MESSAGE(WM_USER_COLORCHANGE, OnColorChange)
  88. ON_MESSAGE(WM_USER_MYRBUTTONDOWN, OnMyRButtonDown)
  89. ON_MESSAGE(WM_APP_STKRECEIVER_DATA, OnStkReceiverData)
  90. END_MESSAGE_MAP()
  91. /////////////////////////////////////////////////////////////////////////////
  92. // CGraphView construction/destruction
  93. CGraphView::CGraphView()
  94. {
  95. }
  96. CGraphView::~CGraphView()
  97. {
  98. }
  99. void CGraphView::ResetClientRect( )
  100. {
  101. CRect rectClient;
  102. GetClientRect( &rectClient );
  103. m_graph.ResetClient( rectClient );
  104. }
  105. void CGraphView::ChangeKType( int ktype )
  106. {
  107. m_graph.SetKType( ktype );
  108. m_graph.ResetIndex( );
  109. Invalidate( );
  110. }
  111. void CGraphView::ChangeKFormat( int kformat )
  112. {
  113. m_graph.SetKFormat( kformat );
  114. m_graph.ResetIndex( );
  115. Invalidate( );
  116. }
  117. void CGraphView::OnToggleKType()
  118. {
  119. int ktype = m_graph.GetKType();
  120. ktype ++;
  121. if( ktype > CKData::ktypeMax )
  122. ktype = CKData::ktypeMin;
  123. ChangeKType( ktype );
  124. }
  125. void CGraphView::OnToggleKFormat( int kformat )
  126. {
  127. int nOld = m_graph.GetKFormat();
  128. if( nOld == kformat )
  129. ChangeKFormat( CKData::formatOriginal );
  130. else
  131. ChangeKFormat( kformat );
  132. }
  133. void CGraphView::ChangeMaindataType( int maindatatype )
  134. {
  135. m_graph.SetMaindataType( maindatatype );
  136. m_graph.ResetIndex( );
  137. Invalidate( );
  138. }
  139. void CGraphView::ChangeKLineMode( int klineMode )
  140. {
  141. m_graph.SetKLineMode( klineMode );
  142. m_graph.ResetIndex( );
  143. Invalidate( );
  144. }
  145. void CGraphView::OnTechParametersChange( )
  146. {
  147. m_graph.ClearTechniqueCache( );
  148. }
  149. BOOL CGraphView::PreCreateWindow(CREATESTRUCT& cs)
  150. {
  151. // TODO: Modify the Window class or styles here by modifying
  152. //  the CREATESTRUCT cs
  153. return CView::PreCreateWindow(cs);
  154. }
  155. void CGraphView::OnInitialUpdate() 
  156. {
  157. CView::OnInitialUpdate();
  158. // TODO: Add your specialized code here and/or call the base class
  159. OnUpdate( NULL, UPDATE_HINT_GRAPHVIEW, NULL );
  160. }
  161. void CGraphView::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint) 
  162. {
  163. // TODO: Add your specialized code here and/or call the base class
  164. if( UPDATE_HINT_GRAPHVIEW != lHint && UPDATE_HINT_GRAPHVIEW_NOTRELOADDATA != lHint )
  165. return;
  166. if( !IsWindowVisible() )
  167. return;
  168. SetFocus( );
  169. CStockInfo info;
  170. if( AfxGetProfile().GetCurrentStock( &info ) )
  171. {
  172. m_graph.SetCurStock( info );
  173. m_graph.PrepareStockData( UPDATE_HINT_GRAPHVIEW_NOTRELOADDATA != lHint );
  174. }
  175. else
  176. {
  177. m_graph.SetCurStock( STKLIB_CODE_MAIN );
  178. m_graph.PrepareStockData( UPDATE_HINT_GRAPHVIEW_NOTRELOADDATA != lHint );
  179. AfxGetProfile().SetCurrentStock( STKLIB_CODE_MAIN, FALSE );
  180. }
  181. Invalidate( );
  182. CMainFrame * pFrame = AfxGetMainFrame();
  183. if( pFrame )
  184. pFrame->m_SearchBox.SetCurrentWindowText( );
  185. }
  186. BOOL CGraphView::PreTranslateMessage(MSG* pMsg) 
  187. {
  188. if( WM_KEYDOWN == pMsg->message )
  189. {
  190. switch( pMsg->wParam )
  191. {
  192. case VK_F5:
  193. {
  194. AfxSwitchToStaticView( RUNTIME_CLASS(CRealTimeView) );
  195. CRealTimeView * pView = AfxGetRealTimeView( );
  196. if( pView )
  197. pView->ChangeDrawMode( CRealTime::modePriceLine );
  198. }
  199. return TRUE;
  200. }
  201. }
  202. return CView::PreTranslateMessage(pMsg);
  203. }
  204. /////////////////////////////////////////////////////////////////////////////
  205. // CGraphView drawing
  206. void CGraphView::OnDraw(CDC* pDC)
  207. {
  208. CStaticDoc* pDoc = GetDocument();
  209. ASSERT_VALID(pDoc);
  210. // TODO: add draw code for native data here
  211. CRect rectClient;
  212. GetClientRect( &rectClient );
  213. m_graph.Redraw( pDC, rectClient );
  214. }
  215. /////////////////////////////////////////////////////////////////////////////
  216. // CGraphView printing
  217. BOOL CGraphView::OnPreparePrinting(CPrintInfo* pInfo)
  218. {
  219. // default preparation
  220. return DoPreparePrinting(pInfo);
  221. }
  222. void CGraphView::OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo)
  223. {
  224. // TODO: add extra initialization before printing
  225. CView::OnBeginPrinting( pDC, pInfo );
  226. }
  227. void CGraphView::OnEndPrinting(CDC* pDC, CPrintInfo* pInfo)
  228. {
  229. // TODO: add cleanup after printing
  230. CView::OnEndPrinting( pDC, pInfo );
  231. }
  232. void CGraphView::OnPrint(CDC* pDC, CPrintInfo* pInfo)
  233. {
  234. // TODO: add customized printing code here
  235. pDC->SetMapMode( MM_ISOTROPIC );
  236. CRect rectClient( 0, 0, 1020, 586 );
  237. // GetClientRect( &rectClient );
  238. pDC->SetWindowOrg( rectClient.left, rectClient.top );
  239. pDC->SetWindowExt( rectClient.Width(), rectClient.Height() );
  240. pDC->SetViewportOrg( pInfo->m_rectDraw.left, pInfo->m_rectDraw.top );
  241. pDC->SetViewportExt( pInfo->m_rectDraw.Width(), pInfo->m_rectDraw.Height() );
  242. m_graph.Redraw( pDC, rectClient );
  243. CRect rectKData = m_graph.GetKDataRect();
  244. rectKData.InflateRect( -2, -1, 2, 1 );
  245. m_graph.DrawKData( pDC, m_graph.GetKDataRect() );
  246. // CView::OnPrint(pDC,pInfo);
  247. }
  248. /////////////////////////////////////////////////////////////////////////////
  249. // CGraphView diagnostics
  250. #ifdef _DEBUG
  251. void CGraphView::AssertValid() const
  252. {
  253. CView::AssertValid();
  254. }
  255. void CGraphView::Dump(CDumpContext& dc) const
  256. {
  257. CView::Dump(dc);
  258. }
  259. #endif //_DEBUG
  260. /////////////////////////////////////////////////////////////////////////////
  261. // CGraphView message handlers
  262. int CGraphView::OnCreate(LPCREATESTRUCT lpCreateStruct) 
  263. {
  264. if (CView::OnCreate(lpCreateStruct) == -1)
  265. return -1;
  266. // TODO: Add your specialized creation code here
  267. CFont font;
  268. if( !font.CreateStockObject( DEFAULT_GUI_FONT ) )
  269. font.CreateStockObject( ANSI_VAR_FONT );
  270. SetFont( &font );
  271. m_graph.SetParent( this );
  272. // tab
  273. if (!m_wndReportTab.Create(WS_VISIBLE|WS_CHILD,CRect(0,0,180,19),this,IDC_GRAPHVIEW_REPORTTAB))
  274. return -1;
  275. CString strName;
  276. strName.LoadString( IDS_GRAPHTAB_PARAM );
  277. m_wndReportTab.Addtab( this, strName, -1);
  278. strName.LoadString( IDS_GRAPHTAB_COST );
  279. m_wndReportTab.Addtab( this, strName, -1);
  280. strName.LoadString( IDS_GRAPHTAB_FLAME );
  281. m_wndReportTab.Addtab( this, strName, -1);
  282. strName.LoadString( IDS_GRAPHTAB_ACTIVITY );
  283. m_wndReportTab.Addtab( this, strName, -1);
  284. m_wndReportTab.SetColorTabs(AfxGetProfile().GetColor(CColorClass::clrGraphBK));
  285. m_wndReportTab.SetSelectTabColor( AfxGetProfile().GetColor(CColorClass::clrGraphBK),
  286. AfxGetProfile().GetColor(CColorClass::clrTitle) );
  287. m_wndReportTab.SetAutoAjust(FALSE);
  288. m_wndReportTab.ShowButtonClose(FALSE);
  289. m_wndReportTab.SetALingTabs( CGuiTabWnd::ALN_BOTTOM );
  290. // 实时行情刷新
  291. AfxGetStkReceiver().AddRcvDataWnd( GetSafeHwnd() );
  292. return 0;
  293. }
  294. void CGraphView::OnSelchangeReporttab(NMHDR* pNMHDR, LRESULT* pResult) 
  295. {
  296. int nCur = m_wndReportTab.GetCurtab();
  297. CRect rect = m_wndReportTab.GetTabRect( nCur );
  298. switch( nCur )
  299. {
  300. case GV_REPORTTAB_PARAM:
  301. m_graph.SetReportWhat( CStockGraph::reportParam );
  302. break;
  303. case GV_REPORTTAB_COST:
  304. m_graph.SetReportWhat( CStockGraph::reportCost );
  305. break;
  306. case GV_REPORTTAB_FLAME:
  307. m_graph.SetReportWhat( CStockGraph::reportFlame );
  308. break;
  309. case GV_REPORTTAB_ACTIVITY:
  310. m_graph.SetReportWhat( CStockGraph::reportActivity );
  311. break;
  312. default:;
  313. }
  314. m_graph.DrawReportRegion( NULL );
  315. *pResult = 0;
  316. }
  317. void CGraphView::OnWindowPosChanged(WINDOWPOS FAR* lpwndpos) 
  318. {
  319. CView::OnWindowPosChanged(lpwndpos);
  320. if( !(lpwndpos->flags & SWP_NOSIZE) || !(lpwndpos->flags & SWP_NOMOVE)
  321. || (lpwndpos->flags & SWP_SHOWWINDOW) )
  322. {
  323. CRect rect;
  324. GetClientRect( &rect );
  325. if( ::IsWindow(m_wndReportTab.GetSafeHwnd()) )
  326. m_wndReportTab.SetWindowPos( NULL, rect.right-172, rect.bottom-19, 0, 0, SWP_NOSIZE | SWP_SHOWWINDOW );
  327. }
  328. }
  329. void CGraphView::OnDestroy() 
  330. {
  331. // 停止行情刷新通知消息
  332. AfxGetStkReceiver().RemoveRcvDataWnd( GetSafeHwnd() );
  333. CView::OnDestroy();
  334. }
  335. void CGraphView::OnActivateView(BOOL bActivate, CView* pActivateView, CView* pDeactiveView) 
  336. {
  337. // TODO: Add your specialized code here and/or call the base class
  338. if( bActivate )
  339. OnUpdate( NULL, UPDATE_HINT_GRAPHVIEW_NOTRELOADDATA, NULL );
  340. CView::OnActivateView(bActivate, pActivateView, pDeactiveView);
  341. }
  342. BOOL CGraphView::OnEraseBkgnd(CDC* pDC) 
  343. {
  344. // TODO: Add your message handler code here and/or call default
  345. if( pDC && pDC->IsKindOf(RUNTIME_CLASS(CDC)) )
  346. {
  347. CRect rect;
  348. GetClientRect( &rect );
  349. CBrush brush;
  350. brush.CreateSolidBrush( AfxGetProfile().GetColor(CColorClass::clrGraphBK) );
  351. pDC->FillRect( &rect, &brush );
  352. return TRUE;
  353. }
  354. return CView::OnEraseBkgnd(pDC);
  355. }
  356. LRESULT CGraphView::OnGetViewTitle(WPARAM wParam, LPARAM lParam)
  357. {
  358. CString strTitle;
  359. strTitle.LoadString( IDS_TITLE_GRAPHVIEW );
  360. lstrcpyn((LPTSTR)lParam, (LPCTSTR)strTitle, wParam);
  361. if ((int)wParam > strTitle.GetLength())
  362. wParam = strTitle.GetLength();
  363. return wParam;
  364. }
  365. LRESULT CGraphView::OnGetViewCmdid(WPARAM wParam, LPARAM lParam)
  366. {
  367. if( lParam )
  368. *((LPARAM *)lParam) = ID_VIEW_GRAPH;
  369. return 0L;
  370. }
  371. LRESULT CGraphView::OnColorChange(WPARAM wParam, LPARAM lParam)
  372. {
  373. m_wndReportTab.SetColorTabs(AfxGetProfile().GetColor(CColorClass::clrGraphBK));
  374. m_wndReportTab.SetSelectTabColor( AfxGetProfile().GetColor(CColorClass::clrGraphBK),
  375. AfxGetProfile().GetColor(CColorClass::clrTitle) );
  376. Invalidate( );
  377. return 0L;
  378. }
  379. LRESULT CGraphView::OnStkReceiverData(WPARAM wParam, LPARAM lParam)
  380. {
  381. return m_graph.OnStkReceiverData(wParam,lParam);
  382. }
  383. void CGraphView::OnLButtonDown(UINT nFlags, CPoint point) 
  384. {
  385. m_graph.OnLButtonDown( nFlags, point, IsSHIFTpressed(), IsCTRLpressed() );
  386. CView::OnLButtonDown(nFlags, point);
  387. }
  388. void CGraphView::OnLButtonUp(UINT nFlags, CPoint point) 
  389. {
  390. m_graph.OnLButtonUp( nFlags, point, IsSHIFTpressed(), IsCTRLpressed() );
  391. CView::OnLButtonUp(nFlags, point);
  392. }
  393. void CGraphView::OnMouseMove(UINT nFlags, CPoint point) 
  394. {
  395. m_graph.OnMouseMove( nFlags, point );
  396. CView::OnMouseMove(nFlags, point);
  397. }
  398. void CGraphView::OnLButtonDblClk(UINT nFlags, CPoint point) 
  399. {
  400. m_graph.OnLButtonDblClk( nFlags, point, IsSHIFTpressed(), IsCTRLpressed() );
  401. CView::OnLButtonDblClk(nFlags, point);
  402. }
  403. LRESULT CGraphView::OnMyRButtonDown(WPARAM wParam, LPARAM lParam) 
  404. {
  405. UINT nFlags = wParam;
  406. CPoint point( (lParam & 0x0000ffff), ((lParam & 0xffff0000) >> 16) );
  407. m_graph.OnRButtonDown( nFlags, point, IsSHIFTpressed(), IsCTRLpressed() );
  408. return 0L;
  409. }
  410. void CGraphView::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) 
  411. {
  412. switch( nChar )
  413. {
  414. case VK_RETURN:
  415. m_graph.OnReturn( IsSHIFTpressed(), IsCTRLpressed() );
  416. break;
  417. case VK_UP:
  418. m_graph.ExpandUp( IsSHIFTpressed() );
  419. break;
  420. case VK_DOWN:
  421. m_graph.ExpandDown( IsSHIFTpressed() );
  422. break;
  423. case VK_LEFT:
  424. if(IsCTRLpressed())
  425. m_graph.PageLeft( IsSHIFTpressed() );
  426. else
  427. m_graph.MoveLeft( IsSHIFTpressed() );
  428. break;
  429. case VK_RIGHT:
  430. if(IsCTRLpressed())
  431. m_graph.PageRight( IsSHIFTpressed() );
  432. else
  433. m_graph.MoveRight( IsSHIFTpressed() );
  434. break;
  435. case VK_HOME:
  436. m_graph.MoveHome( IsSHIFTpressed() );
  437. break;
  438. case VK_END:
  439. m_graph.MoveEnd( IsSHIFTpressed() );
  440. break;
  441. case VK_PRIOR: // Page Up
  442. OnViewPrev( );
  443. break;
  444. case VK_NEXT: // Page Down
  445. OnViewNext( );
  446. break;
  447. case VK_F8:
  448. OnToggleKType( );
  449. break;
  450. case VK_ESCAPE:
  451. m_graph.ResetIndexCurrent( );
  452. Invalidate( );
  453. break;
  454. }
  455. CView::OnKeyDown(nChar, nRepCnt, nFlags);
  456. }
  457. void CGraphView::OnViewPday() { ChangeKType( CKData::ktypeDay ); }
  458. void CGraphView::OnViewPweek() { ChangeKType( CKData::ktypeWeek ); }
  459. void CGraphView::OnViewPmonth() { ChangeKType( CKData::ktypeMonth ); }
  460. void CGraphView::OnViewPmin5() { ChangeKType( CKData::ktypeMin5 ); }
  461. void CGraphView::OnViewPmin15() { ChangeKType( CKData::ktypeMin15 ); }
  462. void CGraphView::OnViewPmin30() { ChangeKType( CKData::ktypeMin30 ); }
  463. void CGraphView::OnViewPmin60() { ChangeKType( CKData::ktypeMin60 ); }
  464. void CGraphView::OnUpdateViewPday(CCmdUI* pCmdUI) { pCmdUI->SetCheck( CKData::ktypeDay == m_graph.GetKType() ); }
  465. void CGraphView::OnUpdateViewPweek(CCmdUI* pCmdUI) { pCmdUI->SetCheck( CKData::ktypeWeek == m_graph.GetKType() ); }
  466. void CGraphView::OnUpdateViewPmonth(CCmdUI* pCmdUI) { pCmdUI->SetCheck( CKData::ktypeMonth == m_graph.GetKType() ); }
  467. void CGraphView::OnUpdateViewPmin5(CCmdUI* pCmdUI) { pCmdUI->SetCheck( CKData::ktypeMin5 == m_graph.GetKType() ); }
  468. void CGraphView::OnUpdateViewPmin15(CCmdUI* pCmdUI) { pCmdUI->SetCheck( CKData::ktypeMin15 == m_graph.GetKType() ); }
  469. void CGraphView::OnUpdateViewPmin30(CCmdUI* pCmdUI) { pCmdUI->SetCheck( CKData::ktypeMin30 == m_graph.GetKType() ); }
  470. void CGraphView::OnUpdateViewPmin60(CCmdUI* pCmdUI) { pCmdUI->SetCheck( CKData::ktypeMin60 == m_graph.GetKType() ); }
  471. void CGraphView::OnViewLeft() { m_graph.MoveLeft( ); }
  472. void CGraphView::OnViewRight() { m_graph.MoveRight( ); }
  473. void CGraphView::OnViewPageleft() { m_graph.PageLeft( ); }
  474. void CGraphView::OnViewPageright() { m_graph.PageRight( ); }
  475. void CGraphView::OnViewHome() { m_graph.MoveHome( ); }
  476. void CGraphView::OnViewEnd() { m_graph.MoveEnd( ); }
  477. void CGraphView::OnViewZoomin() { m_graph.ExpandUp( ); }
  478. void CGraphView::OnViewZoomout() { m_graph.ExpandDown( ); }
  479. void CGraphView::OnViewPrev() 
  480. {
  481. CStockInfo info;
  482. if( AfxGetProfile().GetPrevStock( &info ) )
  483. OnUpdate( NULL, UPDATE_HINT_GRAPHVIEW, NULL );
  484. }
  485. void CGraphView::OnViewNext() 
  486. {
  487. CStockInfo info;
  488. if( AfxGetProfile().GetNextStock( &info ) )
  489. OnUpdate( NULL, UPDATE_HINT_GRAPHVIEW, NULL );
  490. }
  491. void CGraphView::OnViewInsert()
  492. {
  493. m_graph.OnInsert( );
  494. }
  495. void CGraphView::OnViewTechRange( UINT nCmdID )
  496. {
  497. if( nCmdID < ID_VIEW_TECH_START || nCmdID > ID_VIEW_TECH_END )
  498. {
  499. ASSERT( FALSE );
  500. return;
  501. }
  502. UINT nID = nCmdID - ID_VIEW_TECH_START;
  503. if( nID > STT_MAX )
  504. nID = nID-STT_MAX-1+STT_USER_MIN;
  505. AfxGetProfile().ToggleGraphViewTech( nID );
  506. CRect rectClient;
  507. GetClientRect( &rectClient );
  508. m_graph.ResetClient(rectClient );
  509. Invalidate( );
  510. }
  511. void CGraphView::OnUpdateViewTechRange(CCmdUI* pCmdUI)
  512. {
  513. UINT nCmdID = pCmdUI->m_nID;
  514. if( nCmdID < ID_VIEW_TECH_START || nCmdID > ID_VIEW_TECH_END )
  515. {
  516. ASSERT( FALSE );
  517. return;
  518. }
  519. UINT nID = nCmdID - ID_VIEW_TECH_START;
  520. if( nID > STT_MAX )
  521. nID = nID-STT_MAX-1+STT_USER_MIN;
  522. pCmdUI->SetCheck( AfxGetProfile().IsGraphTechShow( nID ) );
  523. }
  524. // K Format
  525. void CGraphView::OnViewNoresumedr() { OnToggleKFormat( CKData::formatOriginal ); }
  526. void CGraphView::OnViewResumedrup() { OnToggleKFormat( CKData::formatXDRup ); }
  527. void CGraphView::OnViewResumedrdown(){ OnToggleKFormat( CKData::formatXDRdown ); }
  528. void CGraphView::OnUpdateViewNoresumedr(CCmdUI* pCmdUI) { pCmdUI->SetCheck( CKData::formatOriginal == m_graph.GetKFormat() ); }
  529. void CGraphView::OnUpdateViewResumedrup(CCmdUI* pCmdUI) { pCmdUI->SetCheck( CKData::formatXDRup == m_graph.GetKFormat() ); }
  530. void CGraphView::OnUpdateViewResumedrdown(CCmdUI* pCmdUI) { pCmdUI->SetCheck( CKData::formatXDRdown == m_graph.GetKFormat() ); }
  531. // Main data Type
  532. void CGraphView::OnViewMaindataclose(){ ChangeMaindataType( CKData::mdtypeClose ); }
  533. void CGraphView::OnViewMaindataopen(){ ChangeMaindataType( CKData::mdtypeOpen ); }
  534. void CGraphView::OnViewMaindataaverage(){ChangeMaindataType( CKData::mdtypeAverage ); }
  535. void CGraphView::OnUpdateViewMaindataclose(CCmdUI* pCmdUI) { pCmdUI->SetCheck( CKData::mdtypeClose == m_graph.GetMaindataType() ); }
  536. void CGraphView::OnUpdateViewMaindataopen(CCmdUI* pCmdUI) { pCmdUI->SetCheck( CKData::mdtypeOpen == m_graph.GetMaindataType() ); }
  537. void CGraphView::OnUpdateViewMaindataaverage(CCmdUI* pCmdUI){ pCmdUI->SetCheck( CKData::mdtypeAverage == m_graph.GetMaindataType() ); }
  538. // kline Mode
  539. void CGraphView::OnViewKlinecandle() { ChangeKLineMode( CStockGraph::klineCandle ); }
  540. void CGraphView::OnViewKlineamerica() { ChangeKLineMode( CStockGraph::klineAmerica ); }
  541. void CGraphView::OnViewKlinetower() { ChangeKLineMode( CStockGraph::klineTower ); }
  542. void CGraphView::OnUpdateViewKlinecandle(CCmdUI* pCmdUI) { pCmdUI->SetCheck( CStockGraph::klineCandle == m_graph.GetKLineMode() ); }
  543. void CGraphView::OnUpdateViewKlineamerica(CCmdUI* pCmdUI) { pCmdUI->SetCheck( CStockGraph::klineAmerica == m_graph.GetKLineMode() ); }
  544. void CGraphView::OnUpdateViewKlinetower(CCmdUI* pCmdUI) { pCmdUI->SetCheck( CStockGraph::klineTower == m_graph.GetKLineMode() ); }
  545. void CGraphView::OnViewHidethistech() 
  546. {
  547. m_graph.HideSelectedTech( );
  548. }
  549. void CGraphView::OnUpdateViewHidethistech(CCmdUI* pCmdUI) 
  550. {
  551. pCmdUI->Enable(STT_INVALID != m_graph.GetSelectedTech());
  552. }
  553. void CGraphView::OnViewThistechparam() 
  554. {
  555. m_graph.AdjustSelectedTech();
  556. }
  557. void CGraphView::OnUpdateViewThistechparam(CCmdUI* pCmdUI) 
  558. {
  559. pCmdUI->Enable(STT_INVALID != m_graph.GetSelectedTech());
  560. }