CommandPanelDlg.cpp
Upload User: kairuinn
Upload Date: 2009-02-07
Package Size: 2922k
Code Size: 5k
Category:

Graph program

Development Platform:

Visual C++

  1. // CommandPanelDlg.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "..//Solidgraph.h"
  5. #include "CommandPanelDlg.h"
  6. #include "GetDialogs//GetPointDlg.h"
  7. #include "GetDialogs//GetVectorDlg.h"
  8. #include "GetDialogs//GetNumberDlg.h"
  9. #include "GetDialogs//GetObjectsDlg.h"
  10. #include "GetDialogs//GetOneDlg.h"
  11. #include "GetDialogs//SelectPointDlg.h"
  12. // CCommandPanelDlg dialog
  13. IMPLEMENT_DYNAMIC(CCommandPanelDlg, CDialog)
  14. CCommandPanelDlg::CCommandPanelDlg(CWnd* pParent /*=NULL*/)
  15. : CDialog(CCommandPanelDlg::IDD, pParent)
  16. {
  17. }
  18. CCommandPanelDlg::~CCommandPanelDlg()
  19. {
  20. }
  21. bool CCommandPanelDlg::RemoveAllDialogs()
  22. {
  23. m_wndRollupCtrl.RemoveAllPages();
  24. RecalcPlaces();
  25. return true;
  26. }
  27. void  CCommandPanelDlg::DrawGroupFrame(CDC* pDC, const CRect& rct, 
  28.    const int leftLab, const int rightLab)
  29. {
  30. ::DrawGroupFrame(pDC,rct,leftLab,rightLab);
  31. }
  32. void CCommandPanelDlg::DoDataExchange(CDataExchange* pDX)
  33. {
  34. CDialog::DoDataExchange(pDX);
  35. }
  36. BEGIN_MESSAGE_MAP(CCommandPanelDlg, CDialog)
  37. ON_WM_CREATE()
  38. ON_WM_SIZE()
  39. ON_WM_ERASEBKGND()
  40. END_MESSAGE_MAP()
  41. CWnd*  CCommandPanelDlg::GetDialogsContainerWindow()
  42. {
  43. return &m_wndRollupCtrl;
  44. }
  45. bool CCommandPanelDlg::AddDialog(IBaseInterfaceOfGetDialogs* dlg, const char* cptn,
  46. bool radio)
  47. {
  48. if (dlg==NULL)
  49. {
  50. ASSERT(0);
  51. return false;
  52. }
  53. m_wndRollupCtrl.InsertPage(cptn, dlg, radio, FALSE);
  54. return true;
  55. }
  56. IBaseInterfaceOfGetDialogs*  CCommandPanelDlg::AddDialog(IBaseInterfaceOfGetDialogs::DLG_TYPE dlgT, 
  57.  const char* cptn,
  58.  bool radio)
  59. {
  60. APP_SWITCH_RESOURCE
  61. switch(dlgT) 
  62. {
  63. case IBaseInterfaceOfGetDialogs::GET_POINT_DLG:
  64. {
  65. CGetPointDlg* dl = new CGetPointDlg;
  66. dl->Create(MAKEINTRESOURCE(IDD_GET_POINT_DLG), &m_wndRollupCtrl);
  67. m_wndRollupCtrl.InsertPage(cptn, dl ,radio);
  68. return dl;
  69. }
  70. break;
  71. case IBaseInterfaceOfGetDialogs::GET_VECTOR_DLG:
  72. {
  73. CGetVectorDlg* dl = new CGetVectorDlg;
  74. dl->Create(MAKEINTRESOURCE(IDD_GET_VECTOR_DLG), &m_wndRollupCtrl);
  75. m_wndRollupCtrl.InsertPage(cptn, dl ,radio);
  76. return dl;
  77. }
  78. break;
  79. case IBaseInterfaceOfGetDialogs::GET_NUMBER_DLG:
  80. {
  81. CGetNumberDlg* dl = new CGetNumberDlg;
  82. dl->Create(MAKEINTRESOURCE(IDD_GET_NUMBER_DLG), &m_wndRollupCtrl);
  83. m_wndRollupCtrl.InsertPage(cptn, dl ,radio);
  84. return dl;
  85. }
  86. break;
  87. case IBaseInterfaceOfGetDialogs::GET_OBJECTS_DLG:
  88. {
  89. CGetObjectsDlg* dl = new CGetObjectsDlg;
  90. dl->Create(MAKEINTRESOURCE(IDD_GET_OBJECTS_DLG), &m_wndRollupCtrl);
  91. m_wndRollupCtrl.InsertPage(cptn, dl ,radio);
  92. return dl;
  93. }
  94. break;
  95. case IBaseInterfaceOfGetDialogs::SELECT_POINT_DLG:
  96. {
  97. CSelectPointDlg* dl = new CSelectPointDlg;
  98. dl->Create(MAKEINTRESOURCE(IDD_SELECT_POINT_DLG), &m_wndRollupCtrl);
  99. m_wndRollupCtrl.InsertPage(cptn, dl ,radio);
  100. return dl;
  101. }
  102. break;
  103. case IBaseInterfaceOfGetDialogs::COMBO_DLG:
  104. {
  105. CGetOneDlg* dl = new CGetOneDlg;
  106. dl->Create(MAKEINTRESOURCE(IDD_GET_ONE_DGL), &m_wndRollupCtrl);
  107. m_wndRollupCtrl.InsertPage(cptn, dl ,radio);
  108. return dl;
  109. }
  110. break;
  111. default:
  112. return NULL;
  113. }
  114. return NULL;
  115. }
  116. bool  CCommandPanelDlg::RemoveDialog(IBaseInterfaceOfGetDialogs* ddd)
  117. {
  118. return m_wndRollupCtrl.RemovePage(ddd);
  119. }
  120. bool  CCommandPanelDlg::RemoveDialog(unsigned int d_numb)
  121. {
  122. return m_wndRollupCtrl.RemovePage(d_numb);
  123. }
  124. bool  CCommandPanelDlg::RenameRadio(unsigned int ind, const char* lab)
  125. {
  126. return m_wndRollupCtrl.RenamePage(ind,lab);
  127. }
  128. void   CCommandPanelDlg::EnableRadio(unsigned int ind,bool enbl)
  129. {
  130. m_wndRollupCtrl.EnableRadio(ind, enbl);
  131. }
  132. void   CCommandPanelDlg::SetActiveRadio(unsigned int ind)
  133. {
  134. m_wndRollupCtrl.SetActiveRadio(ind);
  135. }
  136. int CCommandPanelDlg::OnCreate(LPCREATESTRUCT lpCreateStruct)
  137. {
  138. if (CDialog::OnCreate(lpCreateStruct) == -1)
  139. return -1;
  140. m_wndRollupCtrl.Create(WS_VISIBLE|WS_CHILD, 
  141. CRect(0,0,187,162), this, 1);
  142. //Add some pages
  143. return 0;
  144. }
  145. void  CCommandPanelDlg::RecalcPlaces()
  146. {
  147. if (!::IsWindow(m_hWnd))
  148. return;
  149. RECT  mainRct;
  150. this->GetWindowRect(&mainRct);
  151. int   mainXSz = mainRct.right - mainRct.left;
  152. int   mainYSz = mainRct.bottom - mainRct.top;
  153. int curYPos=0;
  154. m_wndRollupCtrl.SetWindowPos(&wndTop,0,curYPos,mainXSz,mainYSz-curYPos
  155. ,SWP_SHOWWINDOW);
  156. Invalidate();
  157. }
  158. void CCommandPanelDlg::OnSize(UINT nType, int cx, int cy)
  159. {
  160. CDialog::OnSize(nType, cx, cy);
  161. RecalcPlaces();
  162. }
  163. BOOL CCommandPanelDlg::DestroyWindow()
  164. {
  165. RemoveAllDialogs();
  166. return CDialog::DestroyWindow();
  167. }
  168. void CCommandPanelDlg::OnOK()
  169. {
  170. // TODO: Add your specialized code here and/or call the base class
  171. //CDialog::OnOK();
  172. }
  173. void CCommandPanelDlg::OnCancel()
  174. {
  175. // TODO: Add your specialized code here and/or call the base class
  176. //CDialog::OnCancel();
  177. }
  178. #include "..//MemDC.h"
  179. #define USE_MEM_DC // Comment this out, if you don't want to use CMemDC
  180. BOOL CCommandPanelDlg::OnEraseBkgnd(CDC* pDC)
  181. {
  182. #ifdef USE_MEM_DC
  183. CMemDC memDC(pDC);
  184. #else
  185. CDC* memDC = pDC;
  186. #endif
  187. CRect rrr;
  188. GetClientRect(rrr);
  189. themeData.DrawThemedRect(&memDC,&rrr,FALSE);
  190. return TRUE;//CDialog::OnEraseBkgnd(pDC);
  191. }