NewDialogBar.cpp
上传用户:ckg1000
上传日期:2013-01-26
资源大小:630k
文件大小:14k
源码类别:

CAD

开发平台:

Visual C++

  1. // NewDialogBar.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "CAD2006.h"
  5. #include "NewDialogBar.h"
  6. #include "newtoolbar.h"
  7. #include "polygon.h"
  8. #ifdef _DEBUG
  9. #define new DEBUG_NEW
  10. #undef THIS_FILE
  11. static char THIS_FILE[] = __FILE__;
  12. #endif
  13. /////////////////////////////////////////////////////////////////////////////
  14. // NewDialogBar dialog
  15. #include "MainFrm.h"
  16. #include "CAD2006Doc.h"
  17. extern enum SHAPE;
  18. NewDialogBar::NewDialogBar(CWnd* pParent /*=NULL*/)
  19. {
  20. //{{AFX_DATA_INIT(NewDialogBar)
  21. //}}AFX_DATA_INIT
  22. }
  23. void NewDialogBar::DoDataExchange(CDataExchange* pDX)
  24. {
  25. CDialogBar::DoDataExchange(pDX);
  26. /* DDX_Control(pDX, IDC_BUTTON_ARROW, m_arrow);
  27. DDX_Control(pDX, IDC_BUTTON_ZOOM, m_zoom);
  28. DDX_Control(pDX, IDC_BUTTON_TRIGON, m_trigon);
  29. DDX_Control(pDX, IDC_BUTTON_SETCOL, m_setcol);
  30. DDX_Control(pDX, IDC_BUTTON_SELECT, m_select);
  31. DDX_Control(pDX, IDC_BUTTON_ROUND, m_round);
  32. DDX_Control(pDX, IDC_BUTTON_RECT, m_rect);
  33. DDX_Control(pDX, IDC_BUTTON_POLYGON, m_polygon);
  34. DDX_Control(pDX, IDC_BUTTON_MSL, m_msl);
  35. DDX_Control(pDX, IDC_BUTTON_LINE, m_line);
  36. DDX_Control(pDX, IDC_BUTTON_FOREBK, m_forebk);
  37. DDX_Control(pDX, IDC_BUTTON_ELLIPSE, m_ellipse);
  38. DDX_Control(pDX, IDC_BUTTON_EDDY, m_eddy);
  39. DDX_Control(pDX, IDC_BUTTON_CORNER, m_corner);
  40. DDX_Control(pDX, IDC_BUTTON_BACKBK, m_backbk);
  41. DDX_Control(pDX, IDC_BUTTON_ARC, m_arc);*/
  42. //{{AFX_DATA_MAP(NewDialogBar)
  43. //}}AFX_DATA_MAP
  44. }
  45. BEGIN_MESSAGE_MAP(NewDialogBar, CDialogBar)
  46. //{{AFX_MSG_MAP(NewDialogBar)
  47. ON_BN_CLICKED(IDC_BUTTON_ZOOM, OnButtonZoom)
  48. ON_BN_CLICKED(IDC_BUTTON_TRIGON, OnButtonTrigon)
  49. ON_BN_CLICKED(IDC_BUTTON_RECT, OnButtonRect)
  50. ON_BN_CLICKED(IDC_BUTTON_POLYGON, OnButtonPolygon)
  51. ON_BN_CLICKED(IDC_BUTTON_MSL, OnButtonMsl)
  52. ON_BN_CLICKED(IDC_BUTTON_LINE, OnButtonLine)
  53. ON_BN_CLICKED(IDC_BUTTON_EDDY, OnButtonEddy)
  54. ON_BN_CLICKED(IDC_BUTTON_ARROW, OnButtonArrow)
  55. ON_BN_CLICKED(IDC_BUTTON_CIRCLE, OnButtonCircle)
  56. ON_BN_CLICKED(IDC_BUTTON_FILL, OnButtonFill)
  57. ON_BN_CLICKED(IDC_BUTTON_FONT, OnButtonFont)
  58. ON_BN_CLICKED(IDC_BUTTON_MOVE, OnButtonMove)
  59. //}}AFX_MSG_MAP
  60. END_MESSAGE_MAP()
  61. /////////////////////////////////////////////////////////////////////////////
  62. // NewDialogBar message handlers
  63. void NewDialogBar::InitDialogBar()
  64. {
  65. // UpdateData(false);
  66. CBitmap arrow,move,line,trigon,rect,circle,font,polygon,zoom,eddy,msl,fill;
  67. arrow.LoadBitmap(IDB_BITMAP_CHOOSE);
  68. move.LoadBitmap(IDB_BITMAP_SELECT);
  69. line.LoadBitmap(IDB_BITMAP_LINE);
  70. trigon.LoadBitmap(IDB_BITMAP_TRIANGLE);
  71. rect.LoadBitmap(IDB_BITMAP_RECT);
  72. circle.LoadBitmap(IDB_BITMAP_CIRCLE);
  73. font.LoadBitmap(IDB_BITMAP_TEXT);
  74. polygon.LoadBitmap(IDB_BITMAP_POLYGON);
  75. zoom.LoadBitmap(IDB_BITMAP_ZOOM);
  76. eddy.LoadBitmap(IDB_BITMAP_ROTATE);
  77. msl.LoadBitmap(IDB_BITMAP_MIRROR);
  78. fill.LoadBitmap(IDB_BITMAP_BGCOLOR);
  79. CButton *Arrow = (CButton *)GetDlgItem(IDC_BUTTON_ARROW);
  80. CButton *Move = (CButton *)GetDlgItem(IDC_BUTTON_MOVE);
  81. CButton *Line = (CButton *)GetDlgItem(IDC_BUTTON_LINE);
  82. CButton *Trigon = (CButton *)GetDlgItem(IDC_BUTTON_TRIGON);
  83. CButton *Rect = (CButton *)GetDlgItem(IDC_BUTTON_RECT);
  84. CButton *Circle = (CButton *)GetDlgItem(IDC_BUTTON_CIRCLE);
  85. CButton *Font = (CButton *)GetDlgItem(IDC_BUTTON_FONT);
  86. CButton *Polygon = (CButton *)GetDlgItem(IDC_BUTTON_POLYGON);
  87. CButton *Zoom = (CButton *)GetDlgItem(IDC_BUTTON_ZOOM);
  88. CButton *Eddy = (CButton *)GetDlgItem(IDC_BUTTON_EDDY);
  89. CButton *MSL = (CButton *)GetDlgItem(IDC_BUTTON_MSL);
  90. CButton *Fill = (CButton *)GetDlgItem(IDC_BUTTON_FILL);
  91. Arrow->SetBitmap((HBITMAP) arrow.Detach());
  92. Move->SetBitmap((HBITMAP) move.Detach());
  93. Line->SetBitmap((HBITMAP) line.Detach());
  94. Trigon->SetBitmap((HBITMAP) trigon.Detach());
  95. Rect->SetBitmap((HBITMAP) rect.Detach());
  96. Circle->SetBitmap((HBITMAP) circle.Detach());
  97. Font->SetBitmap((HBITMAP) font.Detach());
  98. Polygon->SetBitmap((HBITMAP) polygon.Detach());
  99. Zoom->SetBitmap((HBITMAP) zoom.Detach());
  100. Eddy->SetBitmap((HBITMAP) eddy.Detach());
  101. MSL->SetBitmap((HBITMAP) msl.Detach());
  102. Fill->SetBitmap((HBITMAP) fill.Detach());
  103. }
  104. void NewDialogBar::OnButtonZoom() 
  105. {
  106. // TODO: Add your control notification handler code here
  107. CMainFrame* MainFrame = (CMainFrame *)::AfxGetApp()->m_pMainWnd;
  108. CCAD2006Doc* m_pDoc = (CCAD2006Doc*)MainFrame->GetActiveDocument();
  109. CButton *m_angle = (CButton *)MainFrame->m_wndTrigon.GetDlgItem(IDC_EDIT_ANGLE);
  110. m_angle->EnableWindow(false);
  111. m_pDoc->m_tool = zoom;
  112. }
  113. void NewDialogBar::OnButtonTrigon() 
  114. {
  115. // TODO: Add your control notification handler code here
  116. CMainFrame* MainFrame = (CMainFrame *)::AfxGetApp()->m_pMainWnd;
  117. CCAD2006Doc* m_pDoc = (CCAD2006Doc*)MainFrame->GetActiveDocument();
  118. MainFrame->m_wndTrigon.m_ComShape.ResetContent();
  119. MainFrame->m_wndTrigon.m_ComShape.AddString("三角形");
  120. MainFrame->m_wndTrigon.m_ComShape.SetCurSel(0);
  121. CButton *m_angle = (CButton *)MainFrame->m_wndTrigon.GetDlgItem(IDC_EDIT_ANGLE);
  122. ShowCombox();
  123. m_angle->EnableWindow(false);
  124. m_pDoc->m_shape = trigon;
  125. m_pDoc->m_tool = tool;
  126. //m_pDoc->m_shapearray.Add((CObject*)new CShape);
  127. }
  128. void NewDialogBar::OnButtonRect() 
  129. {
  130. // TODO: Add your control notification handler code here
  131. CMainFrame* MainFrame = (CMainFrame *)::AfxGetApp()->m_pMainWnd;
  132. CCAD2006Doc* m_pDoc = (CCAD2006Doc*)MainFrame->GetActiveDocument();
  133. MainFrame->m_wndTrigon.m_ComShape.ResetContent();
  134. MainFrame->m_wndTrigon.m_ComShape.AddString("正方形");
  135. MainFrame->m_wndTrigon.m_ComShape.AddString("矩形");
  136. MainFrame->m_wndTrigon.m_ComShape.SetCurSel(0);
  137. CButton *m_angle = (CButton *)MainFrame->m_wndTrigon.GetDlgItem(IDC_EDIT_ANGLE);
  138. ShowCombox();
  139. m_angle->EnableWindow(false);
  140. m_pDoc->m_shape = rect;
  141. m_pDoc->m_tool = tool;
  142. // m_pDoc->m_shapearray.Add((CObject*)new CShape);
  143. }
  144. void NewDialogBar::OnButtonPolygon() 
  145. {
  146. // TODO: Add your control notification handler code here
  147. CMainFrame* MainFrame = (CMainFrame *)::AfxGetApp()->m_pMainWnd;
  148. CCAD2006Doc* m_pDoc = (CCAD2006Doc*)MainFrame->GetActiveDocument();
  149. MainFrame->m_wndTrigon.m_ComShape.ResetContent();
  150. MainFrame->m_wndTrigon.m_ComShape.AddString("多边形");
  151. MainFrame->m_wndTrigon.m_ComShape.SetCurSel(0);
  152. CButton *m_angle = (CButton *)MainFrame->m_wndTrigon.GetDlgItem(IDC_EDIT_ANGLE);
  153. ShowCombox();
  154. m_angle->EnableWindow();
  155. m_angle->SetWindowText("5");
  156. m_pDoc->m_shape = polygon;
  157. m_pDoc->m_tool = tool;
  158. // m_pDoc->m_shapearray.Add((CObject*)new CShape);
  159. }
  160. void NewDialogBar::OnButtonMsl() 
  161. {
  162. // TODO: Add your control notification handler code here
  163. CMainFrame* MainFrame = (CMainFrame *)::AfxGetApp()->m_pMainWnd;
  164. CCAD2006Doc* m_pDoc = (CCAD2006Doc*)MainFrame->GetActiveDocument();
  165. CButton *m_angle = (CButton *)MainFrame->m_wndTrigon.GetDlgItem(IDC_EDIT_ANGLE);
  166. m_angle->EnableWindow(false);
  167. m_pDoc->m_tool = msl;
  168. }
  169. void NewDialogBar::OnButtonLine() 
  170. {
  171. // TODO: Add your control notification handler code here
  172. CMainFrame* MainFrame = (CMainFrame *)::AfxGetApp()->m_pMainWnd;
  173. CCAD2006Doc* m_pDoc = (CCAD2006Doc*)MainFrame->GetActiveDocument();
  174. MainFrame->m_wndTrigon.m_ComShape.ResetContent();
  175. MainFrame->m_wndTrigon.m_ComShape.AddString("直线");
  176. MainFrame->m_wndTrigon.m_ComShape.AddString("折线");
  177. MainFrame->m_wndTrigon.m_ComShape.AddString("角度线");
  178. MainFrame->m_wndTrigon.m_ComShape.SetCurSel(2);
  179. CButton *m_angle = (CButton *)MainFrame->m_wndTrigon.GetDlgItem(IDC_EDIT_ANGLE);
  180. ShowCombox();
  181. m_angle->EnableWindow(false);
  182. m_pDoc->m_shape = line;
  183. m_pDoc->m_tool = tool;
  184. // m_pDoc->m_shapearray.Add((CObject*)new CShape);
  185. }
  186. void NewDialogBar::OnButtonFoldline()
  187. {
  188. CMainFrame* MainFrame = (CMainFrame *)::AfxGetApp()->m_pMainWnd;
  189. CCAD2006Doc* m_pDoc = (CCAD2006Doc*)MainFrame->GetActiveDocument();
  190. CButton *m_angle = (CButton *)MainFrame->m_wndTrigon.GetDlgItem(IDC_EDIT_ANGLE);
  191. ShowCombox();
  192. m_angle->EnableWindow(false);
  193. if( m_pDoc->m_shape == (line || linedown || lineangle ))
  194. {
  195. m_pDoc->m_shape = linedown;
  196. m_pDoc->m_tool = tool;
  197. }
  198. else
  199. {
  200. OnButtonLine();
  201. }
  202. m_pDoc->m_shapearray.Add((CObject*)new CShape);
  203. MainFrame->m_wndTrigon.m_ComShape.SetCurSel(1);
  204. }
  205. void NewDialogBar::OnButtonAngleline()
  206. {
  207. CMainFrame* MainFrame = (CMainFrame *)::AfxGetApp()->m_pMainWnd;
  208. CCAD2006Doc* m_pDoc = (CCAD2006Doc*)MainFrame->GetActiveDocument();
  209. CButton *m_angle = (CButton *)MainFrame->m_wndTrigon.GetDlgItem(IDC_EDIT_ANGLE);
  210. ShowCombox();
  211. m_angle->EnableWindow(false);
  212. if( m_pDoc->m_shape == (line || linedown || lineangle) )
  213. {
  214. m_pDoc->m_shape = lineangle;
  215. m_pDoc->m_tool = tool;
  216. }
  217. else
  218. {
  219. OnButtonLine();
  220. }
  221. m_pDoc->m_shapearray.Add((CObject*)new CShape);
  222. MainFrame->m_wndTrigon.m_ComShape.SetCurSel(0);
  223. }
  224. void NewDialogBar::OnButtonEddy() 
  225. {
  226. // TODO: Add your control notification handler code here
  227. CMainFrame* MainFrame = (CMainFrame *)::AfxGetApp()->m_pMainWnd;
  228. CCAD2006Doc* m_pDoc = (CCAD2006Doc*)MainFrame->GetActiveDocument();
  229. CButton *m_angle = (CButton *)MainFrame->m_wndTrigon.GetDlgItem(IDC_EDIT_ANGLE);
  230. m_angle->EnableWindow(true);
  231. m_angle->SetWindowText("30");
  232. CPolygon polygon;
  233. CTrigon trigon;
  234. trigon.SetAngle(30);
  235. polygon.SetAngle(30);
  236. m_pDoc->m_tool = eddy;
  237. }
  238. void NewDialogBar::OnButtonArrow() 
  239. {
  240. // TODO: Add your control notification handler code here
  241. CMainFrame* MainFrame = (CMainFrame *)::AfxGetApp()->m_pMainWnd;
  242. CCAD2006Doc* m_pDoc = (CCAD2006Doc*)MainFrame->GetActiveDocument();
  243. m_pDoc->m_tool = arrow;
  244. m_pDoc->m_shape = shape;
  245. }
  246. BEGIN_EVENTSINK_MAP(NewDialogBar, CDialogBar)
  247.     //{{AFX_EVENTSINK_MAP(NewDialogBar)
  248. ON_EVENT(NewDialogBar, IDC_LABEL_BACKBK, -600 /* Click */, OnClickLabelBackbk, VTS_NONE)
  249. ON_EVENT(NewDialogBar, IDC_LABEL_FORBK, -600 /* Click */, OnClickLabelForbk, VTS_NONE)
  250. //}}AFX_EVENTSINK_MAP
  251. END_EVENTSINK_MAP()
  252. void NewDialogBar::OnClickLabelBackbk() 
  253. {
  254. // TODO: Add your control notification handler code here
  255. CLabelControl *m_backcol = (CLabelControl *)GetDlgItem(IDC_LABEL_BACKBK);
  256. CColorDialog m_backdlg;
  257. if( m_backdlg.DoModal() == IDOK )
  258. {
  259. m_backcol->SetBackColor(m_backdlg.GetColor());
  260. }
  261. m_shape.SetBackColor(m_backdlg.GetColor());
  262. }
  263. void NewDialogBar::OnClickLabelForbk() 
  264. {
  265. // TODO: Add your control notification handler code here
  266. CMainFrame* MainFrame = (CMainFrame *)::AfxGetApp()->m_pMainWnd;
  267. CLabelControl *m_forcol = (CLabelControl *)GetDlgItem(IDC_LABEL_FORBK);
  268. CColorDialog m_fordlg;
  269. if( m_fordlg.DoModal() == IDOK )
  270. {
  271. m_forcol->SetBackColor(m_fordlg.GetColor());
  272. }
  273. if( m_fordlg.GetColor() == RGB(255,0,0) )
  274. {
  275. MainFrame->m_wndTrigon.m_ComCol.SetCurSel(1);
  276. }
  277. else if( m_fordlg.GetColor() == RGB(255,255,0) )
  278. {
  279. MainFrame->m_wndTrigon.m_ComCol.SetCurSel(2);
  280. }
  281. else if( m_fordlg.GetColor() == RGB(0,0,0) )
  282. {
  283. MainFrame->m_wndTrigon.m_ComCol.SetCurSel(0);
  284. }
  285. else
  286. {
  287. MainFrame->m_wndTrigon.m_ComCol.SetCurSel(3);
  288. }
  289. m_shape.SetBorderColor(m_fordlg.GetColor());
  290. }
  291. void NewDialogBar::OnButtonCircle() 
  292. {
  293. // TODO: Add your control notification handler code here
  294. CMainFrame* MainFrame = (CMainFrame *)::AfxGetApp()->m_pMainWnd;
  295. CCAD2006Doc* m_pDoc = (CCAD2006Doc*)MainFrame->GetActiveDocument();
  296. MainFrame->m_wndTrigon.m_ComShape.ResetContent();
  297. MainFrame->m_wndTrigon.m_ComShape.AddString("圆");
  298. MainFrame->m_wndTrigon.m_ComShape.AddString("椭圆");
  299. MainFrame->m_wndTrigon.m_ComShape.AddString("圆弧");
  300. MainFrame->m_wndTrigon.m_ComShape.SetCurSel(1);
  301. CButton *m_angle = (CButton *)MainFrame->m_wndTrigon.GetDlgItem(IDC_EDIT_ANGLE);
  302. ShowCombox();
  303. m_angle->EnableWindow(false);
  304. m_pDoc->m_shape = circle;
  305. m_pDoc->m_tool = tool;
  306. m_pDoc->m_shapearray.Add((CObject*)new CShape);
  307. }
  308. void NewDialogBar::OnButtonCirclemeter()
  309. {
  310. CMainFrame* MainFrame = (CMainFrame *)::AfxGetApp()->m_pMainWnd;
  311. CCAD2006Doc* m_pDoc = (CCAD2006Doc*)MainFrame->GetActiveDocument();
  312. CButton *m_angle = (CButton *)MainFrame->m_wndTrigon.GetDlgItem(IDC_EDIT_ANGLE);
  313. ShowCombox();
  314. m_angle->EnableWindow(true);
  315. if( m_pDoc->m_shape == (circle || ellipse || circlemater) )
  316. {
  317. m_pDoc->m_shape = circlemater;
  318. m_pDoc->m_tool = tool;
  319. }
  320. else
  321. {
  322. OnButtonCircle();
  323. }
  324. m_pDoc->m_shapearray.Add((CObject*)new CShape);
  325. MainFrame->m_wndTrigon.m_ComShape.SetCurSel(2);
  326. }
  327. void NewDialogBar::OnButtonEllipse()
  328. {
  329. CMainFrame* MainFrame = (CMainFrame *)::AfxGetApp()->m_pMainWnd;
  330. CCAD2006Doc* m_pDoc = (CCAD2006Doc*)MainFrame->GetActiveDocument();
  331. CButton *m_angle = (CButton *)MainFrame->m_wndTrigon.GetDlgItem(IDC_EDIT_ANGLE);
  332. ShowCombox();
  333. m_angle->EnableWindow(false);
  334. if( m_pDoc->m_shape == (circle || ellipse || circlemater) )
  335. {
  336. m_pDoc->m_shape = ellipse;
  337. m_pDoc->m_tool = tool;
  338. }
  339. else
  340. {
  341. OnButtonCircle();
  342. }
  343. //m_pDoc->m_shapearray.Add((CObject*)new CShape);
  344. MainFrame->m_wndTrigon.m_ComShape.SetCurSel(0);
  345. }
  346. void NewDialogBar::OnButtonFill() 
  347. {
  348. // TODO: Add your control notification handler code here
  349. CMainFrame* MainFrame = (CMainFrame *)::AfxGetApp()->m_pMainWnd;
  350. CCAD2006Doc* m_pDoc = (CCAD2006Doc*)MainFrame->GetActiveDocument();
  351. CButton *m_angle = (CButton *)MainFrame->m_wndTrigon.GetDlgItem(IDC_EDIT_ANGLE);
  352. m_angle->EnableWindow(false);
  353. }
  354. void NewDialogBar::OnButtonFont() 
  355. {
  356. // TODO: Add your control notification handler code here
  357. CMainFrame* MainFrame = (CMainFrame *)::AfxGetApp()->m_pMainWnd;
  358. CCAD2006Doc* m_pDoc = (CCAD2006Doc*)MainFrame->GetActiveDocument();
  359. MainFrame->m_wndTrigon.m_ComShape.ResetContent();
  360. DisableCombox();
  361. MainFrame->m_wndTrigon.m_ComShape.SetCurSel(0);
  362. m_pDoc->m_shape = font;
  363. m_pDoc->m_tool = tool;
  364. }
  365. void NewDialogBar::OnButtonMove() 
  366. {
  367. // TODO: Add your control notification handler code here
  368. CMainFrame* MainFrame = (CMainFrame *)::AfxGetApp()->m_pMainWnd;
  369. CCAD2006Doc* m_pDoc = (CCAD2006Doc*)MainFrame->GetActiveDocument();
  370. CButton *m_angle = (CButton *)MainFrame->m_wndTrigon.GetDlgItem(IDC_EDIT_ANGLE);
  371. m_angle->EnableWindow(false);
  372. m_pDoc->m_tool = move;
  373. }
  374. void NewDialogBar::ShowCombox()
  375. {
  376. CMainFrame* MainFrame = (CMainFrame *)::AfxGetApp()->m_pMainWnd;
  377. MainFrame->m_wndTrigon.m_ComMode.EnableWindow(true);
  378. MainFrame->m_wndTrigon.m_ComSize.EnableWindow(true);
  379. MainFrame->m_wndTrigon.m_ComCol.EnableWindow(true);
  380. }
  381. void NewDialogBar::DisableCombox()
  382. {
  383. CMainFrame* MainFrame = (CMainFrame *)::AfxGetApp()->m_pMainWnd;
  384. MainFrame->m_wndTrigon.m_ComMode.EnableWindow(false);
  385. MainFrame->m_wndTrigon.m_ComSize.EnableWindow(false);
  386. MainFrame->m_wndTrigon.m_ComCol.EnableWindow(false);
  387. }