NewDialogBar.cpp
资源名称:CAD2006.rar [点击查看]
上传用户:ckg1000
上传日期:2013-01-26
资源大小:630k
文件大小:14k
源码类别:
CAD
开发平台:
Visual C++
- // NewDialogBar.cpp : implementation file
- //
- #include "stdafx.h"
- #include "CAD2006.h"
- #include "NewDialogBar.h"
- #include "newtoolbar.h"
- #include "polygon.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // NewDialogBar dialog
- #include "MainFrm.h"
- #include "CAD2006Doc.h"
- extern enum SHAPE;
- NewDialogBar::NewDialogBar(CWnd* pParent /*=NULL*/)
- {
- //{{AFX_DATA_INIT(NewDialogBar)
- //}}AFX_DATA_INIT
- }
- void NewDialogBar::DoDataExchange(CDataExchange* pDX)
- {
- CDialogBar::DoDataExchange(pDX);
- /* DDX_Control(pDX, IDC_BUTTON_ARROW, m_arrow);
- DDX_Control(pDX, IDC_BUTTON_ZOOM, m_zoom);
- DDX_Control(pDX, IDC_BUTTON_TRIGON, m_trigon);
- DDX_Control(pDX, IDC_BUTTON_SETCOL, m_setcol);
- DDX_Control(pDX, IDC_BUTTON_SELECT, m_select);
- DDX_Control(pDX, IDC_BUTTON_ROUND, m_round);
- DDX_Control(pDX, IDC_BUTTON_RECT, m_rect);
- DDX_Control(pDX, IDC_BUTTON_POLYGON, m_polygon);
- DDX_Control(pDX, IDC_BUTTON_MSL, m_msl);
- DDX_Control(pDX, IDC_BUTTON_LINE, m_line);
- DDX_Control(pDX, IDC_BUTTON_FOREBK, m_forebk);
- DDX_Control(pDX, IDC_BUTTON_ELLIPSE, m_ellipse);
- DDX_Control(pDX, IDC_BUTTON_EDDY, m_eddy);
- DDX_Control(pDX, IDC_BUTTON_CORNER, m_corner);
- DDX_Control(pDX, IDC_BUTTON_BACKBK, m_backbk);
- DDX_Control(pDX, IDC_BUTTON_ARC, m_arc);*/
- //{{AFX_DATA_MAP(NewDialogBar)
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(NewDialogBar, CDialogBar)
- //{{AFX_MSG_MAP(NewDialogBar)
- ON_BN_CLICKED(IDC_BUTTON_ZOOM, OnButtonZoom)
- ON_BN_CLICKED(IDC_BUTTON_TRIGON, OnButtonTrigon)
- ON_BN_CLICKED(IDC_BUTTON_RECT, OnButtonRect)
- ON_BN_CLICKED(IDC_BUTTON_POLYGON, OnButtonPolygon)
- ON_BN_CLICKED(IDC_BUTTON_MSL, OnButtonMsl)
- ON_BN_CLICKED(IDC_BUTTON_LINE, OnButtonLine)
- ON_BN_CLICKED(IDC_BUTTON_EDDY, OnButtonEddy)
- ON_BN_CLICKED(IDC_BUTTON_ARROW, OnButtonArrow)
- ON_BN_CLICKED(IDC_BUTTON_CIRCLE, OnButtonCircle)
- ON_BN_CLICKED(IDC_BUTTON_FILL, OnButtonFill)
- ON_BN_CLICKED(IDC_BUTTON_FONT, OnButtonFont)
- ON_BN_CLICKED(IDC_BUTTON_MOVE, OnButtonMove)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // NewDialogBar message handlers
- void NewDialogBar::InitDialogBar()
- {
- // UpdateData(false);
- CBitmap arrow,move,line,trigon,rect,circle,font,polygon,zoom,eddy,msl,fill;
- arrow.LoadBitmap(IDB_BITMAP_CHOOSE);
- move.LoadBitmap(IDB_BITMAP_SELECT);
- line.LoadBitmap(IDB_BITMAP_LINE);
- trigon.LoadBitmap(IDB_BITMAP_TRIANGLE);
- rect.LoadBitmap(IDB_BITMAP_RECT);
- circle.LoadBitmap(IDB_BITMAP_CIRCLE);
- font.LoadBitmap(IDB_BITMAP_TEXT);
- polygon.LoadBitmap(IDB_BITMAP_POLYGON);
- zoom.LoadBitmap(IDB_BITMAP_ZOOM);
- eddy.LoadBitmap(IDB_BITMAP_ROTATE);
- msl.LoadBitmap(IDB_BITMAP_MIRROR);
- fill.LoadBitmap(IDB_BITMAP_BGCOLOR);
- CButton *Arrow = (CButton *)GetDlgItem(IDC_BUTTON_ARROW);
- CButton *Move = (CButton *)GetDlgItem(IDC_BUTTON_MOVE);
- CButton *Line = (CButton *)GetDlgItem(IDC_BUTTON_LINE);
- CButton *Trigon = (CButton *)GetDlgItem(IDC_BUTTON_TRIGON);
- CButton *Rect = (CButton *)GetDlgItem(IDC_BUTTON_RECT);
- CButton *Circle = (CButton *)GetDlgItem(IDC_BUTTON_CIRCLE);
- CButton *Font = (CButton *)GetDlgItem(IDC_BUTTON_FONT);
- CButton *Polygon = (CButton *)GetDlgItem(IDC_BUTTON_POLYGON);
- CButton *Zoom = (CButton *)GetDlgItem(IDC_BUTTON_ZOOM);
- CButton *Eddy = (CButton *)GetDlgItem(IDC_BUTTON_EDDY);
- CButton *MSL = (CButton *)GetDlgItem(IDC_BUTTON_MSL);
- CButton *Fill = (CButton *)GetDlgItem(IDC_BUTTON_FILL);
- Arrow->SetBitmap((HBITMAP) arrow.Detach());
- Move->SetBitmap((HBITMAP) move.Detach());
- Line->SetBitmap((HBITMAP) line.Detach());
- Trigon->SetBitmap((HBITMAP) trigon.Detach());
- Rect->SetBitmap((HBITMAP) rect.Detach());
- Circle->SetBitmap((HBITMAP) circle.Detach());
- Font->SetBitmap((HBITMAP) font.Detach());
- Polygon->SetBitmap((HBITMAP) polygon.Detach());
- Zoom->SetBitmap((HBITMAP) zoom.Detach());
- Eddy->SetBitmap((HBITMAP) eddy.Detach());
- MSL->SetBitmap((HBITMAP) msl.Detach());
- Fill->SetBitmap((HBITMAP) fill.Detach());
- }
- void NewDialogBar::OnButtonZoom()
- {
- // TODO: Add your control notification handler code here
- CMainFrame* MainFrame = (CMainFrame *)::AfxGetApp()->m_pMainWnd;
- CCAD2006Doc* m_pDoc = (CCAD2006Doc*)MainFrame->GetActiveDocument();
- CButton *m_angle = (CButton *)MainFrame->m_wndTrigon.GetDlgItem(IDC_EDIT_ANGLE);
- m_angle->EnableWindow(false);
- m_pDoc->m_tool = zoom;
- }
- void NewDialogBar::OnButtonTrigon()
- {
- // TODO: Add your control notification handler code here
- CMainFrame* MainFrame = (CMainFrame *)::AfxGetApp()->m_pMainWnd;
- CCAD2006Doc* m_pDoc = (CCAD2006Doc*)MainFrame->GetActiveDocument();
- MainFrame->m_wndTrigon.m_ComShape.ResetContent();
- MainFrame->m_wndTrigon.m_ComShape.AddString("三角形");
- MainFrame->m_wndTrigon.m_ComShape.SetCurSel(0);
- CButton *m_angle = (CButton *)MainFrame->m_wndTrigon.GetDlgItem(IDC_EDIT_ANGLE);
- ShowCombox();
- m_angle->EnableWindow(false);
- m_pDoc->m_shape = trigon;
- m_pDoc->m_tool = tool;
- //m_pDoc->m_shapearray.Add((CObject*)new CShape);
- }
- void NewDialogBar::OnButtonRect()
- {
- // TODO: Add your control notification handler code here
- CMainFrame* MainFrame = (CMainFrame *)::AfxGetApp()->m_pMainWnd;
- CCAD2006Doc* m_pDoc = (CCAD2006Doc*)MainFrame->GetActiveDocument();
- MainFrame->m_wndTrigon.m_ComShape.ResetContent();
- MainFrame->m_wndTrigon.m_ComShape.AddString("正方形");
- MainFrame->m_wndTrigon.m_ComShape.AddString("矩形");
- MainFrame->m_wndTrigon.m_ComShape.SetCurSel(0);
- CButton *m_angle = (CButton *)MainFrame->m_wndTrigon.GetDlgItem(IDC_EDIT_ANGLE);
- ShowCombox();
- m_angle->EnableWindow(false);
- m_pDoc->m_shape = rect;
- m_pDoc->m_tool = tool;
- // m_pDoc->m_shapearray.Add((CObject*)new CShape);
- }
- void NewDialogBar::OnButtonPolygon()
- {
- // TODO: Add your control notification handler code here
- CMainFrame* MainFrame = (CMainFrame *)::AfxGetApp()->m_pMainWnd;
- CCAD2006Doc* m_pDoc = (CCAD2006Doc*)MainFrame->GetActiveDocument();
- MainFrame->m_wndTrigon.m_ComShape.ResetContent();
- MainFrame->m_wndTrigon.m_ComShape.AddString("多边形");
- MainFrame->m_wndTrigon.m_ComShape.SetCurSel(0);
- CButton *m_angle = (CButton *)MainFrame->m_wndTrigon.GetDlgItem(IDC_EDIT_ANGLE);
- ShowCombox();
- m_angle->EnableWindow();
- m_angle->SetWindowText("5");
- m_pDoc->m_shape = polygon;
- m_pDoc->m_tool = tool;
- // m_pDoc->m_shapearray.Add((CObject*)new CShape);
- }
- void NewDialogBar::OnButtonMsl()
- {
- // TODO: Add your control notification handler code here
- CMainFrame* MainFrame = (CMainFrame *)::AfxGetApp()->m_pMainWnd;
- CCAD2006Doc* m_pDoc = (CCAD2006Doc*)MainFrame->GetActiveDocument();
- CButton *m_angle = (CButton *)MainFrame->m_wndTrigon.GetDlgItem(IDC_EDIT_ANGLE);
- m_angle->EnableWindow(false);
- m_pDoc->m_tool = msl;
- }
- void NewDialogBar::OnButtonLine()
- {
- // TODO: Add your control notification handler code here
- CMainFrame* MainFrame = (CMainFrame *)::AfxGetApp()->m_pMainWnd;
- CCAD2006Doc* m_pDoc = (CCAD2006Doc*)MainFrame->GetActiveDocument();
- MainFrame->m_wndTrigon.m_ComShape.ResetContent();
- MainFrame->m_wndTrigon.m_ComShape.AddString("直线");
- MainFrame->m_wndTrigon.m_ComShape.AddString("折线");
- MainFrame->m_wndTrigon.m_ComShape.AddString("角度线");
- MainFrame->m_wndTrigon.m_ComShape.SetCurSel(2);
- CButton *m_angle = (CButton *)MainFrame->m_wndTrigon.GetDlgItem(IDC_EDIT_ANGLE);
- ShowCombox();
- m_angle->EnableWindow(false);
- m_pDoc->m_shape = line;
- m_pDoc->m_tool = tool;
- // m_pDoc->m_shapearray.Add((CObject*)new CShape);
- }
- void NewDialogBar::OnButtonFoldline()
- {
- CMainFrame* MainFrame = (CMainFrame *)::AfxGetApp()->m_pMainWnd;
- CCAD2006Doc* m_pDoc = (CCAD2006Doc*)MainFrame->GetActiveDocument();
- CButton *m_angle = (CButton *)MainFrame->m_wndTrigon.GetDlgItem(IDC_EDIT_ANGLE);
- ShowCombox();
- m_angle->EnableWindow(false);
- if( m_pDoc->m_shape == (line || linedown || lineangle ))
- {
- m_pDoc->m_shape = linedown;
- m_pDoc->m_tool = tool;
- }
- else
- {
- OnButtonLine();
- }
- m_pDoc->m_shapearray.Add((CObject*)new CShape);
- MainFrame->m_wndTrigon.m_ComShape.SetCurSel(1);
- }
- void NewDialogBar::OnButtonAngleline()
- {
- CMainFrame* MainFrame = (CMainFrame *)::AfxGetApp()->m_pMainWnd;
- CCAD2006Doc* m_pDoc = (CCAD2006Doc*)MainFrame->GetActiveDocument();
- CButton *m_angle = (CButton *)MainFrame->m_wndTrigon.GetDlgItem(IDC_EDIT_ANGLE);
- ShowCombox();
- m_angle->EnableWindow(false);
- if( m_pDoc->m_shape == (line || linedown || lineangle) )
- {
- m_pDoc->m_shape = lineangle;
- m_pDoc->m_tool = tool;
- }
- else
- {
- OnButtonLine();
- }
- m_pDoc->m_shapearray.Add((CObject*)new CShape);
- MainFrame->m_wndTrigon.m_ComShape.SetCurSel(0);
- }
- void NewDialogBar::OnButtonEddy()
- {
- // TODO: Add your control notification handler code here
- CMainFrame* MainFrame = (CMainFrame *)::AfxGetApp()->m_pMainWnd;
- CCAD2006Doc* m_pDoc = (CCAD2006Doc*)MainFrame->GetActiveDocument();
- CButton *m_angle = (CButton *)MainFrame->m_wndTrigon.GetDlgItem(IDC_EDIT_ANGLE);
- m_angle->EnableWindow(true);
- m_angle->SetWindowText("30");
- CPolygon polygon;
- CTrigon trigon;
- trigon.SetAngle(30);
- polygon.SetAngle(30);
- m_pDoc->m_tool = eddy;
- }
- void NewDialogBar::OnButtonArrow()
- {
- // TODO: Add your control notification handler code here
- CMainFrame* MainFrame = (CMainFrame *)::AfxGetApp()->m_pMainWnd;
- CCAD2006Doc* m_pDoc = (CCAD2006Doc*)MainFrame->GetActiveDocument();
- m_pDoc->m_tool = arrow;
- m_pDoc->m_shape = shape;
- }
- BEGIN_EVENTSINK_MAP(NewDialogBar, CDialogBar)
- //{{AFX_EVENTSINK_MAP(NewDialogBar)
- ON_EVENT(NewDialogBar, IDC_LABEL_BACKBK, -600 /* Click */, OnClickLabelBackbk, VTS_NONE)
- ON_EVENT(NewDialogBar, IDC_LABEL_FORBK, -600 /* Click */, OnClickLabelForbk, VTS_NONE)
- //}}AFX_EVENTSINK_MAP
- END_EVENTSINK_MAP()
- void NewDialogBar::OnClickLabelBackbk()
- {
- // TODO: Add your control notification handler code here
- CLabelControl *m_backcol = (CLabelControl *)GetDlgItem(IDC_LABEL_BACKBK);
- CColorDialog m_backdlg;
- if( m_backdlg.DoModal() == IDOK )
- {
- m_backcol->SetBackColor(m_backdlg.GetColor());
- }
- m_shape.SetBackColor(m_backdlg.GetColor());
- }
- void NewDialogBar::OnClickLabelForbk()
- {
- // TODO: Add your control notification handler code here
- CMainFrame* MainFrame = (CMainFrame *)::AfxGetApp()->m_pMainWnd;
- CLabelControl *m_forcol = (CLabelControl *)GetDlgItem(IDC_LABEL_FORBK);
- CColorDialog m_fordlg;
- if( m_fordlg.DoModal() == IDOK )
- {
- m_forcol->SetBackColor(m_fordlg.GetColor());
- }
- if( m_fordlg.GetColor() == RGB(255,0,0) )
- {
- MainFrame->m_wndTrigon.m_ComCol.SetCurSel(1);
- }
- else if( m_fordlg.GetColor() == RGB(255,255,0) )
- {
- MainFrame->m_wndTrigon.m_ComCol.SetCurSel(2);
- }
- else if( m_fordlg.GetColor() == RGB(0,0,0) )
- {
- MainFrame->m_wndTrigon.m_ComCol.SetCurSel(0);
- }
- else
- {
- MainFrame->m_wndTrigon.m_ComCol.SetCurSel(3);
- }
- m_shape.SetBorderColor(m_fordlg.GetColor());
- }
- void NewDialogBar::OnButtonCircle()
- {
- // TODO: Add your control notification handler code here
- CMainFrame* MainFrame = (CMainFrame *)::AfxGetApp()->m_pMainWnd;
- CCAD2006Doc* m_pDoc = (CCAD2006Doc*)MainFrame->GetActiveDocument();
- MainFrame->m_wndTrigon.m_ComShape.ResetContent();
- MainFrame->m_wndTrigon.m_ComShape.AddString("圆");
- MainFrame->m_wndTrigon.m_ComShape.AddString("椭圆");
- MainFrame->m_wndTrigon.m_ComShape.AddString("圆弧");
- MainFrame->m_wndTrigon.m_ComShape.SetCurSel(1);
- CButton *m_angle = (CButton *)MainFrame->m_wndTrigon.GetDlgItem(IDC_EDIT_ANGLE);
- ShowCombox();
- m_angle->EnableWindow(false);
- m_pDoc->m_shape = circle;
- m_pDoc->m_tool = tool;
- m_pDoc->m_shapearray.Add((CObject*)new CShape);
- }
- void NewDialogBar::OnButtonCirclemeter()
- {
- CMainFrame* MainFrame = (CMainFrame *)::AfxGetApp()->m_pMainWnd;
- CCAD2006Doc* m_pDoc = (CCAD2006Doc*)MainFrame->GetActiveDocument();
- CButton *m_angle = (CButton *)MainFrame->m_wndTrigon.GetDlgItem(IDC_EDIT_ANGLE);
- ShowCombox();
- m_angle->EnableWindow(true);
- if( m_pDoc->m_shape == (circle || ellipse || circlemater) )
- {
- m_pDoc->m_shape = circlemater;
- m_pDoc->m_tool = tool;
- }
- else
- {
- OnButtonCircle();
- }
- m_pDoc->m_shapearray.Add((CObject*)new CShape);
- MainFrame->m_wndTrigon.m_ComShape.SetCurSel(2);
- }
- void NewDialogBar::OnButtonEllipse()
- {
- CMainFrame* MainFrame = (CMainFrame *)::AfxGetApp()->m_pMainWnd;
- CCAD2006Doc* m_pDoc = (CCAD2006Doc*)MainFrame->GetActiveDocument();
- CButton *m_angle = (CButton *)MainFrame->m_wndTrigon.GetDlgItem(IDC_EDIT_ANGLE);
- ShowCombox();
- m_angle->EnableWindow(false);
- if( m_pDoc->m_shape == (circle || ellipse || circlemater) )
- {
- m_pDoc->m_shape = ellipse;
- m_pDoc->m_tool = tool;
- }
- else
- {
- OnButtonCircle();
- }
- //m_pDoc->m_shapearray.Add((CObject*)new CShape);
- MainFrame->m_wndTrigon.m_ComShape.SetCurSel(0);
- }
- void NewDialogBar::OnButtonFill()
- {
- // TODO: Add your control notification handler code here
- CMainFrame* MainFrame = (CMainFrame *)::AfxGetApp()->m_pMainWnd;
- CCAD2006Doc* m_pDoc = (CCAD2006Doc*)MainFrame->GetActiveDocument();
- CButton *m_angle = (CButton *)MainFrame->m_wndTrigon.GetDlgItem(IDC_EDIT_ANGLE);
- m_angle->EnableWindow(false);
- }
- void NewDialogBar::OnButtonFont()
- {
- // TODO: Add your control notification handler code here
- CMainFrame* MainFrame = (CMainFrame *)::AfxGetApp()->m_pMainWnd;
- CCAD2006Doc* m_pDoc = (CCAD2006Doc*)MainFrame->GetActiveDocument();
- MainFrame->m_wndTrigon.m_ComShape.ResetContent();
- DisableCombox();
- MainFrame->m_wndTrigon.m_ComShape.SetCurSel(0);
- m_pDoc->m_shape = font;
- m_pDoc->m_tool = tool;
- }
- void NewDialogBar::OnButtonMove()
- {
- // TODO: Add your control notification handler code here
- CMainFrame* MainFrame = (CMainFrame *)::AfxGetApp()->m_pMainWnd;
- CCAD2006Doc* m_pDoc = (CCAD2006Doc*)MainFrame->GetActiveDocument();
- CButton *m_angle = (CButton *)MainFrame->m_wndTrigon.GetDlgItem(IDC_EDIT_ANGLE);
- m_angle->EnableWindow(false);
- m_pDoc->m_tool = move;
- }
- void NewDialogBar::ShowCombox()
- {
- CMainFrame* MainFrame = (CMainFrame *)::AfxGetApp()->m_pMainWnd;
- MainFrame->m_wndTrigon.m_ComMode.EnableWindow(true);
- MainFrame->m_wndTrigon.m_ComSize.EnableWindow(true);
- MainFrame->m_wndTrigon.m_ComCol.EnableWindow(true);
- }
- void NewDialogBar::DisableCombox()
- {
- CMainFrame* MainFrame = (CMainFrame *)::AfxGetApp()->m_pMainWnd;
- MainFrame->m_wndTrigon.m_ComMode.EnableWindow(false);
- MainFrame->m_wndTrigon.m_ComSize.EnableWindow(false);
- MainFrame->m_wndTrigon.m_ComCol.EnableWindow(false);
- }