MainFrm.cpp
资源名称:44757463.rar [点击查看]
上传用户:lj3531212
上传日期:2007-06-18
资源大小:346k
文件大小:24k
源码类别:
绘图程序
开发平台:
Visual C++
- // MainFrm.cpp : implementation of the CMainFrame class
- //
- #include "stdafx.h"
- #include "GraphSoft.h"
- #include "MainFrm.h"
- #include "GraphSoftView.h"
- #include "ColorSetDlg.h"
- #include "FillSetDlg.h"
- #include "LineMenu.h"
- #include "FullScreenHandler.h"
- #include "FullViewBtn.h"
- #include "undodlg.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CMainFrame
- IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd)
- BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
- //{{AFX_MSG_MAP(CMainFrame)
- ON_WM_CREATE()
- ON_NOTIFY(TBN_DROPDOWN, IDR_PROPERTY_BAR, OnToolbarDropDown)
- ON_WM_CLOSE()
- ON_MESSAGE(WM_SETCOLOR,OnSetColor)
- ON_MESSAGE(WM_SETFILLCOLOR,OnSetFillColor)
- ON_MESSAGE(WM_SETFILLSTYLE,OnSetFillStyle)
- ON_COMMAND(ID_PENWIDTH_FIVE, OnPenwidthFive)
- ON_COMMAND(ID_PENWIDTH_ONE, OnPenwidthOne)
- ON_COMMAND(ID_PENWIDTH_SEVEN, OnPenwidthSeven)
- ON_COMMAND(ID_PENWIDTH_THREE, OnPenwidthThree)
- ON_COMMAND(ID_PENWIDTH_TWO, OnPenwidthTwo)
- ON_COMMAND(ID_SET_FILLSTYLE, OnSetFillstyle)
- ON_WM_DRAWITEM()
- ON_WM_MEASUREITEM()
- ON_WM_INITMENU()
- ON_COMMAND(ID_FULLSCREEN, OnFullscreen)
- ON_COMMAND(ID_FULLWINDOW, OnFullwindow)
- ON_WM_GETMINMAXINFO()
- ON_COMMAND(ID_SELECT_COLOR, OnSelectColor)
- ON_COMMAND(ID_EDIT_REDO, OnEditRedo)
- ON_COMMAND(ID_EDIT_UNDO, OnEditUndo)
- ON_UPDATE_COMMAND_UI(ID_EDIT_REDO, OnUpdateEditRedo)
- ON_UPDATE_COMMAND_UI(ID_EDIT_UNDO, OnUpdateEditUndo)
- ON_NOTIFY(TBN_DROPDOWN, IDR_MAINFRAME, OnToolbarDropDown)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- static UINT indicators[] =
- {
- ID_SEPARATOR,// status line indicator
- ID_SEPARATOR,
- ID_INDICATOR_CAPS,
- ID_INDICATOR_NUM,
- ID_INDICATOR_SCRL,
- };
- /////////////////////////////////////////////////////////////////////////////
- // CMainFrame construction/destruction
- CMainFrame::CMainFrame()
- {
- // TODO: add member initialization code here
- m_pdlgSetColor=new CColorSetDlg(0,this);
- m_pdlgSetFillColor=new CColorSetDlg(1,this);
- m_pdlgFillStyle=new CFillSetDlg(this);
- m_pdlgSetColor->Create(CColorSetDlg::IDD, this);
- m_pdlgSetColor->ShowWindow(SW_SHOW);
- m_pdlgSetColor->PostMessage(WM_COMMAND,IDCANCEL);
- m_pdlgSetFillColor->Create(CColorSetDlg::IDD, this);
- m_pdlgSetFillColor->ShowWindow(SW_SHOW);
- m_pdlgSetFillColor->PostMessage(WM_COMMAND,IDCANCEL);
- m_pdlgFillStyle->Create(CFillSetDlg::IDD,this);
- m_pUndoDlg=NULL;
- }
- CMainFrame::~CMainFrame()
- {
- m_pdlgSetColor->DestroyWindow();
- delete m_pdlgSetColor;
- m_pdlgSetFillColor->DestroyWindow();
- delete m_pdlgSetFillColor;
- m_pdlgFillStyle->DestroyWindow();
- delete m_pdlgFillStyle;
- delete this->m_wndFullView.m_pBtn ;
- delete m_pUndoDlg;
- }
- int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
- {
- if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
- return -1;
- if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT| CCS_ADJUSTABLE, WS_CHILD | WS_VISIBLE | CBRS_TOP
- | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_FIXED,CRect(0,0,0,0),IDR_MAINFRAME) ||
- !m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
- {
- TRACE0("Failed to create toolbarn");
- return -1; // fail to create
- }
- if (!m_wndStatusBar.Create(this) ||
- !m_wndStatusBar.SetIndicators(indicators,
- sizeof(indicators)/sizeof(UINT)))
- {
- TRACE0("Failed to create status barn");
- return -1; // fail to create
- }
- m_wndStatusBar.SetPaneInfo(0,ID_SEPARATOR,SBPS_STRETCH,200);
- m_wndStatusBar.SetPaneStyle(1,SBPS_STRETCH);
- //m_wndStatusBar.SetPaneInfo(1,ID_INDICATOR_MOUSEPOSITION,SBPS_NORMAL,100);
- //GraphBar
- if (!m_wndTBarGraph.CreateEx(this, TBSTYLE_FLAT| CCS_ADJUSTABLE, WS_CHILD | WS_VISIBLE | CBRS_LEFT
- | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY ) ||
- !m_wndTBarGraph.LoadToolBar(IDR_DRAW_GRAPH))
- {
- TRACE0("Failed to create toolbarn");
- return -1; // fail to create
- }
- //Graph Operation Bar
- if (!m_wndTBarGraphOp.CreateEx(this, TBSTYLE_FLAT| CCS_ADJUSTABLE, WS_CHILD | WS_VISIBLE | CBRS_LEFT
- | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY) ||
- !m_wndTBarGraphOp.LoadToolBar(IDR_GRAPH_OPERATION))
- {
- TRACE0("Failed to create toolbarn");
- return -1; // fail to create
- }
- //PropertyBar
- if (!m_wndPropertyBar.CreateEx(this, TBSTYLE_FLAT| CCS_ADJUSTABLE, WS_CHILD | WS_VISIBLE | CBRS_TOP
- | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY| CBRS_SIZE_FIXED,CRect(0,0,0,0),IDR_PROPERTY_BAR ) ||
- !m_wndPropertyBar.LoadToolBar(IDR_PROPERTY_BAR))
- {
- TRACE0("Failed to create toolbarn");
- return -1; // fail to create
- }
- //WindowBar
- if (!m_wndWindow.CreateEx(this, TBSTYLE_FLAT| CCS_ADJUSTABLE, WS_CHILD | WS_VISIBLE | CBRS_TOP
- | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY| CBRS_SIZE_FIXED,CRect(0,0,0,0),IDR_WINDOWS ) ||
- !m_wndWindow.LoadToolBar(IDR_WINDOWS))
- {
- TRACE0("Failed to create toolbarn");
- return -1; // fail to create
- }
- /////////////////////////////////////////////////
- CRect rect;
- int index=0;
- //让工具栏具有处理下拉箭头的能力
- DWORD dwExStyle = TBSTYLE_EX_DRAWDDARROWS;
- m_wndPropertyBar.GetToolBarCtrl().SendMessage(TB_SETEXTENDEDSTYLE, 0, (LPARAM)dwExStyle);
- m_wndToolBar.GetToolBarCtrl().SendMessage(TB_SETEXTENDEDSTYLE, 0, (LPARAM)dwExStyle);
- //用SetButtonStyle()方法在选定的地方添加下拉箭头按钮
- //笔宽
- DWORD dwStyle = m_wndPropertyBar.GetButtonStyle(m_wndPropertyBar.CommandToIndex(ID_SELECT_PENWIDTH));
- dwStyle |= TBSTYLE_DROPDOWN;
- m_wndPropertyBar.SetButtonStyle(m_wndPropertyBar.CommandToIndex(ID_SELECT_PENWIDTH), dwStyle);
- //颜色
- dwStyle = m_wndPropertyBar.GetButtonStyle(m_wndPropertyBar.CommandToIndex(ID_SELECT_COLOR));
- dwStyle |= TBSTYLE_DROPDOWN;
- m_wndPropertyBar.SetButtonStyle(m_wndPropertyBar.CommandToIndex(ID_SELECT_COLOR), dwStyle);
- //填充颜色
- dwStyle = m_wndPropertyBar.GetButtonStyle(m_wndPropertyBar.CommandToIndex(ID_SELECT_FILL_COLOR));
- dwStyle |= TBSTYLE_DROPDOWN;
- m_wndPropertyBar.SetButtonStyle(m_wndPropertyBar.CommandToIndex(ID_SELECT_FILL_COLOR), dwStyle);
- //填充类型
- dwStyle = m_wndPropertyBar.GetButtonStyle(m_wndPropertyBar.CommandToIndex(ID_SET_FILLSTYLE));
- dwStyle |= TBSTYLE_DROPDOWN;
- m_wndPropertyBar.SetButtonStyle(m_wndPropertyBar.CommandToIndex(ID_SET_FILLSTYLE), dwStyle);
- //撤消
- dwStyle = m_wndToolBar.GetButtonStyle(m_wndToolBar.CommandToIndex(ID_EDIT_UNDO));
- dwStyle |= TBSTYLE_DROPDOWN;
- m_wndToolBar.SetButtonStyle(m_wndToolBar.CommandToIndex(ID_EDIT_UNDO), dwStyle);
- //恢复
- dwStyle = m_wndToolBar.GetButtonStyle(m_wndToolBar.CommandToIndex(ID_EDIT_REDO));
- dwStyle |= TBSTYLE_DROPDOWN;
- m_wndToolBar.SetButtonStyle(m_wndToolBar.CommandToIndex(ID_EDIT_REDO), dwStyle);
- /////////////////////////////////////////////////////
- // TODO: Delete these three lines if you don't want the toolbar to
- // be dockable
- //设置工具拦的位置
- m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
- m_wndTBarGraph.EnableDocking(CBRS_ALIGN_ANY);
- m_wndTBarGraphOp.EnableDocking(CBRS_ALIGN_ANY);
- m_wndPropertyBar.EnableDocking(CBRS_ALIGN_ANY);
- m_wndWindow.EnableDocking(CBRS_ALIGN_ANY);
- EnableDocking(CBRS_ALIGN_ANY);
- DockControlBar(&m_wndToolBar);
- DockControlBar(&m_wndTBarGraph);
- DockControlBar(&m_wndTBarGraphOp);
- RecalcLayout(TRUE);
- m_wndToolBar.GetWindowRect(&rect);
- rect.left+=1;
- rect.right+=1;
- DockControlBar(&m_wndPropertyBar,AFX_IDW_DOCKBAR_TOP,&rect);
- m_wndPropertyBar.GetWindowRect(&rect);
- rect.left+=1;
- rect.right+=1;
- DockControlBar(&m_wndWindow,AFX_IDW_DOCKBAR_TOP,&rect);
- //创建全景视图
- if (!m_wndFullView.Create(this,IDD_FULLVIEW,WS_CHILD | WS_VISIBLE | CBRS_TOOLTIPS | CBRS_RIGHT|CBRS_FLYBY | CBRS_SIZE_DYNAMIC,IDD_FULLVIEW))
- {
- TRACE0("Failed to create DlgBarn");
- return -1;
- }
- CRect rect2 ;
- m_wndFullView.GetWindowRect(&rect2) ;
- m_wndFullView.MoveWindow(4,42,172,143,true);
- m_wndFullView.EnableDocking(CBRS_ALIGN_LEFT|CBRS_ALIGN_RIGHT) ;
- CString title;
- title.LoadString(IDS_FULLVIEWTITLE);
- m_wndFullView.SetWindowText(title);
- DockControlBar(&m_wndFullView) ;
- m_wndFullView.m_pBtn = new CFullViewBtn();
- m_wndFullView.GetWindowRect(&rect) ;
- m_wndFullView.CalcViewSize() ;
- m_wndFullView.m_pBtn->Create("TEST",BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE,m_wndFullView.m_pBtn->m_size,&m_wndFullView,0) ;
- return 0;
- }
- BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
- {
- if( !CFrameWnd::PreCreateWindow(cs) )
- return FALSE;
- // TODO: Modify the Window class or styles here by modifying
- // the CREATESTRUCT cs
- return TRUE;
- }
- /////////////////////////////////////////////////////////////////////////////
- // CMainFrame diagnostics
- #ifdef _DEBUG
- void CMainFrame::AssertValid() const
- {
- CFrameWnd::AssertValid();
- }
- void CMainFrame::Dump(CDumpContext& dc) const
- {
- CFrameWnd::Dump(dc);
- }
- #endif //_DEBUG
- /////////////////////////////////////////////////////////////////////////////
- // CMainFrame message handlers
- void CMainFrame::OnClose()
- {
- // TODO: Add your message handler code here and/or call default
- CGraphSoftView* pView=(CGraphSoftView*)((CMainFrame*)AfxGetApp()->GetMainWnd())->GetActiveView();
- CGraphSoftDoc* pDoc=pView->GetDocument();
- CString strTitle,strDetail;
- strTitle.LoadString(IDS_FILE_SAVE_TITLE);
- strDetail.LoadString(IDS_FILE_SAVE_STRING);
- if(pDoc->m_pCore->IsAbleToUndo()||pDoc->m_pCore->IsAbleToRedo()){
- int nRtn=MessageBox(strDetail,strTitle,MB_YESNOCANCEL|MB_SYSTEMMODAL);
- if(nRtn==IDYES){
- SendMessage(WM_COMMAND,WPARAM(ID_FILE_SAVE));
- }else if(nRtn==IDCANCEL){
- return ;
- }
- }
- CFrameWnd::OnClose();
- }
- void CMainFrame::OnToolbarDropDown(NMTOOLBAR* pnmtb, LRESULT *plr)
- {
- CWnd *pWnd;
- CRect rect;
- CGraphSoftView* pView=(CGraphSoftView*)((CMainFrame*)AfxGetApp()->GetMainWnd())->GetActiveView();
- CGraphSoftDoc* pDoc=pView->GetDocument();
- switch (pnmtb->iItem)
- {
- case ID_SELECT_PENWIDTH:
- {
- CLineMenu mnLine;
- pWnd = &m_wndPropertyBar;
- pWnd->SendMessage(TB_GETRECT, pnmtb->iItem, (LPARAM)&rect);
- pWnd->ClientToScreen(&rect);
- mnLine.CreatePopupMenu();
- mnLine.AppendMenu(MF_ENABLED,ID_PENWIDTH_ONE,"1 X");
- mnLine.AppendMenu(MF_ENABLED,ID_PENWIDTH_TWO,"2 X");
- mnLine.AppendMenu(MF_ENABLED,ID_PENWIDTH_THREE,"3 X");
- mnLine.AppendMenu(MF_ENABLED,ID_PENWIDTH_FIVE,"5 X");
- mnLine.AppendMenu(MF_ENABLED,ID_PENWIDTH_SEVEN,"7 X");
- mnLine.ChangeStyle(&mnLine);
- mnLine.TrackPopupMenu(TPM_LEFTALIGN ,rect.left, rect.bottom,this);
- mnLine.DestroyMenu();
- break;
- }
- case ID_SELECT_COLOR:
- {
- pWnd = &m_wndPropertyBar;
- pWnd->SendMessage(TB_GETRECT, pnmtb->iItem, (LPARAM)&rect);
- pWnd->ClientToScreen(&rect);
- m_pdlgSetColor->Init();
- m_pdlgSetColor->InitColor(((CGraphSoftView*)((CMainFrame*)AfxGetApp()->GetMainWnd())->GetActiveView())->m_clrCurrentColor);
- m_pdlgSetColor->SetWindowPos(&wndTopMost, rect.left,rect.bottom, 0, 0, SWP_NOSIZE|SWP_NOZORDER);
- m_pdlgSetColor->ShowWindow(SW_SHOW);
- m_pdlgSetColor->SetFocus();
- break;
- }
- case ID_SELECT_FILL_COLOR:
- {
- pWnd = &m_wndPropertyBar;
- pWnd->SendMessage(TB_GETRECT, pnmtb->iItem, (LPARAM)&rect);
- pWnd->ClientToScreen(&rect);
- m_pdlgSetFillColor->Init();
- m_pdlgSetFillColor->InitColor(((CGraphSoftView*)((CMainFrame*)AfxGetApp()->GetMainWnd())->GetActiveView())->m_clrCurrentFill);
- m_pdlgSetFillColor->SetWindowPos(&wndTopMost, rect.left,rect.bottom, 0, 0, SWP_NOSIZE|SWP_NOZORDER);
- m_pdlgSetFillColor->ShowWindow(SW_SHOW);
- m_pdlgSetFillColor->SetFocus();
- break;
- }
- case ID_SET_FILLSTYLE:
- {
- pWnd = &m_wndPropertyBar;
- pWnd->SendMessage(TB_GETRECT, pnmtb->iItem, (LPARAM)&rect);
- pWnd->ClientToScreen(&rect);
- m_pdlgFillStyle->Init();
- m_pdlgFillStyle->SetWindowPos(&wndTopMost, rect.left,rect.bottom, 0, 0, SWP_NOSIZE|SWP_NOZORDER);
- m_pdlgFillStyle->ShowWindow(SW_SHOW);
- m_pdlgFillStyle->SetFocus();
- break;
- }
- case ID_EDIT_UNDO :
- case ID_EDIT_REDO :
- {
- CCore* pCore=pDoc->m_pCore;
- if (m_pUndoDlg == NULL) {
- m_pUndoDlg = new CUndoDlg;
- m_pUndoDlg->Create(IDD_UNDODLG);
- m_pUndoDlg->m_list.m_pParentDlg = m_pUndoDlg;
- }
- if (! m_pUndoDlg->IsWindowVisible()) {
- pWnd = &m_wndToolBar;
- pWnd->SendMessage(TB_GETRECT, pnmtb->iItem, (LPARAM)&rect);
- pWnd->ClientToScreen(&rect);
- CPoint pos;
- pos.x = rect.left;
- pos.y = rect.bottom;
- CRect rcDlg;
- m_pUndoDlg->GetWindowRect(&rcDlg);
- if (pos.x + rcDlg.Width() > ::GetSystemMetrics(SM_CXSCREEN))
- pos.x = rect.right - rcDlg.Width();
- if (pos.y + rcDlg.Height() > ::GetSystemMetrics(SM_CYSCREEN))
- pos.y = rect.top - rcDlg.Height();
- m_pUndoDlg->SetWindowPos(NULL, pos.x, pos.y, 0, 0, SWP_NOSIZE|SWP_NOZORDER);
- m_pUndoDlg->m_list.m_pCore = pCore;
- m_pUndoDlg->m_list.m_nID = pnmtb->iItem;
- m_pUndoDlg->m_list.SetContents();
- switch (m_pUndoDlg->m_list.m_nID) {
- case ID_EDIT_UNDO:
- m_pUndoDlg->m_statusFormatString.LoadString(IDS_EDIT_UNDO_TIMES);
- break;
- case ID_EDIT_REDO:
- m_pUndoDlg->m_statusFormatString.LoadString(IDS_EDIT_REDO_TIMES);
- break;
- }
- m_pUndoDlg->SetStatus(0);
- m_pUndoDlg->ShowWindow(SW_SHOW);
- }
- break ;
- }
- default:
- return;
- }
- return;
- }
- void CMainFrame::ActivateFrame(int nCmdShow)
- {
- // TODO: Add your specialized code here and/or call the base class
- nCmdShow=SW_MAXIMIZE;
- CFrameWnd::ActivateFrame(nCmdShow);
- }
- void CMainFrame::OnSetColor(WPARAM wParam,LPARAM lParam)
- {
- COLORREF color=(COLORREF)wParam;
- if(((CGraphSoftView*)GetActiveView())->m_clrCurrentColor==color){
- return;
- }
- ((CGraphSoftView*)GetActiveView())->m_clrCurrentColor=color;
- CToolBar& wndToolBar = m_wndPropertyBar;
- CToolBarCtrl& toolbar = wndToolBar.GetToolBarCtrl();
- UINT uID = ID_SELECT_COLOR;
- int nIndex = wndToolBar.CommandToIndex(uID);
- if (nIndex >= 0) {
- CBitmap& bitmap = m_colorbmp;
- if (bitmap.GetSafeHandle())
- bitmap.DeleteObject();
- bitmap.LoadBitmap(IDB_BITMAP_LINECOLOR_SET);
- {
- CClientDC dc(this);
- CDC dcMem;
- dcMem.CreateCompatibleDC(&dc);
- dcMem.SelectObject(&bitmap);
- COLORREF clrBk = dcMem.GetPixel(0,0);
- for (int j = 0; j < 12; j++) {
- for (int i = 0; i < 16; i++) {
- if (dcMem.GetPixel(i,j) == clrBk)
- dcMem.SetPixel(i,j,::GetSysColor(COLOR_3DFACE));
- }
- }
- CRect rect(0, 12, 16, 16);
- dcMem.FillRect(rect, &CBrush(color));
- }
- int no = toolbar.AddBitmap(1, &bitmap);
- UINT uStyle ;
- int iImage ;
- wndToolBar.GetButtonInfo ( nIndex, uID, uStyle, iImage );
- wndToolBar.SetButtonInfo ( nIndex, uID, uStyle, no );
- }
- }
- void CMainFrame::OnSetFillColor (WPARAM wParam,LPARAM lParam)
- {
- COLORREF color=(COLORREF)wParam;
- if(((CGraphSoftView*)GetActiveView())->m_clrCurrentFill==color){
- return;
- }
- ((CGraphSoftView*)GetActiveView())->m_clrCurrentFill=color;
- CToolBar& wndToolBar = m_wndPropertyBar;
- CToolBarCtrl& toolbar = wndToolBar.GetToolBarCtrl();
- UINT uID = ID_SELECT_FILL_COLOR;
- int nIndex = wndToolBar.CommandToIndex(uID);
- if (nIndex >= 0) {
- CBitmap& bitmap = m_colorbmp;
- if (bitmap.GetSafeHandle())
- bitmap.DeleteObject();
- bitmap.LoadBitmap(IDB_BITMAP_FILLCOLOR_SET);
- {
- CClientDC dc(this);
- CDC dcMem;
- dcMem.CreateCompatibleDC(&dc);
- dcMem.SelectObject(&bitmap);
- COLORREF clrBk = dcMem.GetPixel(0,0);
- for (int j = 0; j < 12; j++) {
- for (int i = 0; i < 16; i++) {
- if (dcMem.GetPixel(i,j) == clrBk)
- dcMem.SetPixel(i,j,::GetSysColor(COLOR_3DFACE));
- }
- }
- CRect rect(0, 12, 16, 16);
- dcMem.FillRect(rect, &CBrush(color));
- }
- int no = toolbar.AddBitmap(1, &bitmap);
- UINT uStyle ;
- int iImage ;
- wndToolBar.GetButtonInfo ( nIndex, uID, uStyle, iImage );
- wndToolBar.SetButtonInfo ( nIndex, uID, uStyle, no );
- }
- }
- void CMainFrame::OnSetFillStyle (WPARAM wParam,LPARAM lParam)
- {
- int nStyle=(int)wParam;
- if(((CGraphSoftView*)GetActiveView())->m_shapeCurFillStyle==(SHAPE_FILLSTYLE)nStyle){
- return;
- }
- ((CGraphSoftView*)GetActiveView())->m_shapeCurFillStyle=(SHAPE_FILLSTYLE)nStyle;
- CToolBar& wndToolBar = m_wndPropertyBar;
- CToolBarCtrl& toolbar = wndToolBar.GetToolBarCtrl();
- UINT uID = ID_SET_FILLSTYLE;
- int nIndex = wndToolBar.CommandToIndex(uID);
- if (nIndex >= 0) {
- CBitmap& bitmap = m_colorbmp;
- if (bitmap.GetSafeHandle())
- bitmap.DeleteObject();
- switch(nStyle){
- case 0:
- bitmap.LoadBitmap(IDB_GRAPH_NOTFILL);
- break;
- case 1:
- bitmap.LoadBitmap(IDB_GRAPH_SOLIDFILL);
- break;
- default:
- break;
- }
- CClientDC dc(this);
- dc.SelectObject(&bitmap);
- int no = toolbar.AddBitmap(1, &bitmap);
- UINT uStyle ;
- int iImage ;
- wndToolBar.GetButtonInfo ( nIndex, uID, uStyle, iImage );
- wndToolBar.SetButtonInfo ( nIndex, uID, uStyle, no );
- }
- }
- void CMainFrame::OnPenwidthFive()
- {
- // TODO: Add your command handler code here
- if(((CGraphSoftView*)GetActiveView())->m_nCurrentPenWidth==5){
- return;
- }
- ((CGraphSoftView*)GetActiveView())->m_nCurrentPenWidth=5;
- CToolBar& wndToolBar = m_wndPropertyBar;
- CToolBarCtrl& toolbar = wndToolBar.GetToolBarCtrl();
- UINT uID = ID_SELECT_PENWIDTH;
- int nIndex = wndToolBar.CommandToIndex(uID);
- if (nIndex >= 0) {
- CBitmap& bitmap = m_colorbmp;
- if (bitmap.GetSafeHandle())
- bitmap.DeleteObject();
- bitmap.LoadBitmap(IDB_PENWIDTH_FIVE);
- CClientDC dc(this);
- dc.SelectObject(&bitmap);
- int no = toolbar.AddBitmap(1, &bitmap);
- UINT uStyle ;
- int iImage ;
- wndToolBar.GetButtonInfo ( nIndex, uID, uStyle, iImage );
- wndToolBar.SetButtonInfo ( nIndex, uID, uStyle, no );
- }
- }
- void CMainFrame::OnPenwidthOne()
- {
- // TODO: Add your command handler code here
- if(((CGraphSoftView*)GetActiveView())->m_nCurrentPenWidth==1){
- return;
- }
- ((CGraphSoftView*)GetActiveView())->m_nCurrentPenWidth=1;
- CToolBar& wndToolBar = m_wndPropertyBar;
- CToolBarCtrl& toolbar = wndToolBar.GetToolBarCtrl();
- UINT uID = ID_SELECT_PENWIDTH;
- int nIndex = wndToolBar.CommandToIndex(uID);
- if (nIndex >= 0) {
- CBitmap& bitmap = m_colorbmp;
- if (bitmap.GetSafeHandle())
- bitmap.DeleteObject();
- bitmap.LoadBitmap(IDB_PENWIDTH_ONE);
- CClientDC dc(this);
- dc.SelectObject(&bitmap);
- int no = toolbar.AddBitmap(1, &bitmap);
- UINT uStyle ;
- int iImage ;
- wndToolBar.GetButtonInfo ( nIndex, uID, uStyle, iImage );
- wndToolBar.SetButtonInfo ( nIndex, uID, uStyle, no );
- }
- }
- void CMainFrame::OnPenwidthSeven()
- {
- // TODO: Add your command handler code here
- if(((CGraphSoftView*)GetActiveView())->m_nCurrentPenWidth==7){
- return;
- }
- ((CGraphSoftView*)GetActiveView())->m_nCurrentPenWidth=7;
- CToolBar& wndToolBar = m_wndPropertyBar;
- CToolBarCtrl& toolbar = wndToolBar.GetToolBarCtrl();
- UINT uID = ID_SELECT_PENWIDTH;
- int nIndex = wndToolBar.CommandToIndex(uID);
- if (nIndex >= 0) {
- CBitmap& bitmap = m_colorbmp;
- if (bitmap.GetSafeHandle())
- bitmap.DeleteObject();
- bitmap.LoadBitmap(IDB_PENWIDTH_SEVEN);
- CClientDC dc(this);
- dc.SelectObject(&bitmap);
- int no = toolbar.AddBitmap(1, &bitmap);
- UINT uStyle ;
- int iImage ;
- wndToolBar.GetButtonInfo ( nIndex, uID, uStyle, iImage );
- wndToolBar.SetButtonInfo ( nIndex, uID, uStyle, no );
- }
- }
- void CMainFrame::OnPenwidthThree()
- {
- // TODO: Add your command handler code here
- if(((CGraphSoftView*)GetActiveView())->m_nCurrentPenWidth==3){
- return;
- }
- ((CGraphSoftView*)GetActiveView())->m_nCurrentPenWidth=3;
- CToolBar& wndToolBar = m_wndPropertyBar;
- CToolBarCtrl& toolbar = wndToolBar.GetToolBarCtrl();
- UINT uID = ID_SELECT_PENWIDTH;
- int nIndex = wndToolBar.CommandToIndex(uID);
- if (nIndex >= 0) {
- CBitmap& bitmap = m_colorbmp;
- if (bitmap.GetSafeHandle())
- bitmap.DeleteObject();
- bitmap.LoadBitmap(IDB_PENWIDTH_THREE);
- CClientDC dc(this);
- dc.SelectObject(&bitmap);
- int no = toolbar.AddBitmap(1, &bitmap);
- UINT uStyle ;
- int iImage ;
- wndToolBar.GetButtonInfo ( nIndex, uID, uStyle, iImage );
- wndToolBar.SetButtonInfo ( nIndex, uID, uStyle, no );
- }
- }
- void CMainFrame::OnPenwidthTwo()
- {
- // TODO: Add your command handler code here
- if(((CGraphSoftView*)GetActiveView())->m_nCurrentPenWidth==2){
- return;
- }
- ((CGraphSoftView*)GetActiveView())->m_nCurrentPenWidth=2;
- CToolBar& wndToolBar = m_wndPropertyBar;
- CToolBarCtrl& toolbar = wndToolBar.GetToolBarCtrl();
- UINT uID = ID_SELECT_PENWIDTH;
- int nIndex = wndToolBar.CommandToIndex(uID);
- if (nIndex >= 0) {
- CBitmap& bitmap = m_colorbmp;
- if (bitmap.GetSafeHandle())
- bitmap.DeleteObject();
- bitmap.LoadBitmap(IDB_PENWIDTH_TWO);
- CClientDC dc(this);
- dc.SelectObject(&bitmap);
- int no = toolbar.AddBitmap(1, &bitmap);
- UINT uStyle ;
- int iImage ;
- wndToolBar.GetButtonInfo ( nIndex, uID, uStyle, iImage );
- wndToolBar.SetButtonInfo ( nIndex, uID, uStyle, no );
- }
- }
- void CMainFrame::OnSetFillstyle()
- {
- // TODO: Add your command handler code here
- }
- void CMainFrame::OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruct)
- {
- // TODO: Add your message handler code here and/or call default
- if(!nIDCtl) m_menu.DrawItem(lpDrawItemStruct);
- CFrameWnd::OnDrawItem(nIDCtl, lpDrawItemStruct);
- }
- void CMainFrame::OnMeasureItem(int nIDCtl, LPMEASUREITEMSTRUCT lpMeasureItemStruct)
- {
- // TODO: Add your message handler code here and/or call default
- if(!nIDCtl) m_menu.MeasureItem(lpMeasureItemStruct);
- CFrameWnd::OnMeasureItem(nIDCtl, lpMeasureItemStruct);
- }
- void CMainFrame::OnInitMenu(CMenu* pMenu)
- {
- CFrameWnd::OnInitMenu(pMenu);
- // TODO: Add your message handler code here
- m_menu.InitMenu(pMenu,IDR_MAINFRAME,&m_wndToolBar);
- //m_menu.InitMenu(pMenu,IDR_GRAPH_OPERATION,&(((CMainFrame*)(AfxGetApp()->GetMainWnd()))->m_wndTBarGraphOp));
- }
- void CMainFrame::OnFullscreen()
- {
- // TODO: Add your command handler code here
- if (FullScreenHandler.InFullScreenMode())
- {
- FullScreenHandler.Restore(this);
- }else{
- FullScreenHandler.Maximize(this,this->m_pViewActive);
- }
- }
- void CMainFrame::OnFullwindow()
- {
- // TODO: Add your command handler code here
- BOOL bVisible = false ;
- if( m_wndFullView.IsWindowVisible()) bVisible = true ;
- if(bVisible) {
- ShowControlBar(&m_wndFullView,FALSE,FALSE) ;
- }
- else {
- ShowControlBar(&m_wndFullView ,true,FALSE) ;
- }
- }
- void CMainFrame::OnGetMinMaxInfo(MINMAXINFO* lpmmi)
- {
- CSize sz = FullScreenHandler.GetMaxSize();
- lpmmi->ptMaxSize = CPoint(sz);
- lpmmi->ptMaxTrackSize = CPoint(sz);
- }
- void CMainFrame::OnSelectColor()
- {
- // TODO: Add your command handler code here
- }
- void CMainFrame::OnEditRedo()
- {
- // TODO: Add your command handler code here
- CGraphSoftView* pView=(CGraphSoftView*)((CMainFrame*)AfxGetApp()->GetMainWnd())->GetActiveView();
- CGraphSoftDoc* pDoc=pView->GetDocument();
- pDoc->m_pCore->OnEditRedo();
- }
- void CMainFrame::OnEditUndo()
- {
- // TODO: Add your command handler code here
- CGraphSoftView* pView=(CGraphSoftView*)((CMainFrame*)AfxGetApp()->GetMainWnd())->GetActiveView();
- CGraphSoftDoc* pDoc=pView->GetDocument();
- pDoc->m_pCore->OnEditUndo();
- }
- void CMainFrame::OnUpdateEditRedo(CCmdUI* pCmdUI)
- {
- // TODO: Add your command update UI handler code here
- CGraphSoftView* pView=(CGraphSoftView*)((CMainFrame*)AfxGetApp()->GetMainWnd())->GetActiveView();
- CGraphSoftDoc* pDoc=pView->GetDocument();
- pCmdUI->Enable(pDoc->m_pCore->IsAbleToRedo() && pView->m_graph_op!=_graph_edit);
- }
- void CMainFrame::OnUpdateEditUndo(CCmdUI* pCmdUI)
- {
- // TODO: Add your command update UI handler code here
- CGraphSoftView* pView=(CGraphSoftView*)((CMainFrame*)AfxGetApp()->GetMainWnd())->GetActiveView();
- CGraphSoftDoc* pDoc=pView->GetDocument();
- pCmdUI->Enable(pDoc->m_pCore->IsAbleToUndo() && pView->m_graph_op!=_graph_edit);
- }