home *** CD-ROM | disk | FTP | other *** search
- // MiniDraw.cpp : Defines the class behaviors for the application.
- //
-
- #include "stdafx.h"
- #include "MiniDraw.h"
-
- #include "MainFrm.h"
- #include "MiniDDoc.h"
- #include "MiniDrVw.h"
-
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
-
- /////////////////////////////////////////////////////////////////////////////
- // CMiniDrawApp
-
- BEGIN_MESSAGE_MAP(CMiniDrawApp, CWinApp)
- //{{AFX_MSG_MAP(CMiniDrawApp)
- ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
- ON_COMMAND(ID_LINE_DOUBLE, OnLineDouble)
- ON_UPDATE_COMMAND_UI(ID_LINE_DOUBLE, OnUpdateLineDouble)
- ON_COMMAND(ID_LINE_SINGLE, OnLineSingle)
- ON_UPDATE_COMMAND_UI(ID_LINE_SINGLE, OnUpdateLineSingle)
- ON_COMMAND(ID_LINE_TRIPLE, OnLineTriple)
- ON_UPDATE_COMMAND_UI(ID_LINE_TRIPLE, OnUpdateLineTriple)
- ON_COMMAND(ID_TOOLS_CIRCLE, OnToolsCircle)
- ON_UPDATE_COMMAND_UI(ID_TOOLS_CIRCLE, OnUpdateToolsCircle)
- ON_COMMAND(ID_TOOLS_CIRCLEFILL, OnToolsCirclefill)
- ON_UPDATE_COMMAND_UI(ID_TOOLS_CIRCLEFILL, OnUpdateToolsCirclefill)
- ON_COMMAND(ID_TOOLS_LINE, OnToolsLine)
- ON_UPDATE_COMMAND_UI(ID_TOOLS_LINE, OnUpdateToolsLine)
- ON_COMMAND(ID_TOOLS_RECTANGLE, OnToolsRectangle)
- ON_UPDATE_COMMAND_UI(ID_TOOLS_RECTANGLE, OnUpdateToolsRectangle)
- ON_COMMAND(ID_TOOLS_RECTFILL, OnToolsRectfill)
- ON_UPDATE_COMMAND_UI(ID_TOOLS_RECTFILL, OnUpdateToolsRectfill)
- ON_COMMAND(ID_TOOLS_RECTROUND, OnToolsRectround)
- ON_UPDATE_COMMAND_UI(ID_TOOLS_RECTROUND, OnUpdateToolsRectround)
- ON_COMMAND(ID_TOOLS_RECTROUNDFILL, OnToolsRectroundfill)
- ON_UPDATE_COMMAND_UI(ID_TOOLS_RECTROUNDFILL, OnUpdateToolsRectroundfill)
- ON_COMMAND(ID_COLOR_BLACK, OnColorBlack)
- ON_UPDATE_COMMAND_UI(ID_COLOR_BLACK, OnUpdateColorBlack)
- ON_COMMAND(ID_COLOR_BLUE, OnColorBlue)
- ON_UPDATE_COMMAND_UI(ID_COLOR_BLUE, OnUpdateColorBlue)
- ON_COMMAND(ID_COLOR_CUSTOM, OnColorCustom)
- ON_UPDATE_COMMAND_UI(ID_COLOR_CUSTOM, OnUpdateColorCustom)
- ON_COMMAND(ID_COLOR_CYAN, OnColorCyan)
- ON_UPDATE_COMMAND_UI(ID_COLOR_CYAN, OnUpdateColorCyan)
- ON_COMMAND(ID_COLOR_GREEN, OnColorGreen)
- ON_UPDATE_COMMAND_UI(ID_COLOR_GREEN, OnUpdateColorGreen)
- ON_COMMAND(ID_COLOR_MAGENTA, OnColorMagenta)
- ON_UPDATE_COMMAND_UI(ID_COLOR_MAGENTA, OnUpdateColorMagenta)
- ON_COMMAND(ID_COLOR_RED, OnColorRed)
- ON_UPDATE_COMMAND_UI(ID_COLOR_RED, OnUpdateColorRed)
- ON_COMMAND(ID_COLOR_WHITE, OnColorWhite)
- ON_UPDATE_COMMAND_UI(ID_COLOR_WHITE, OnUpdateColorWhite)
- ON_COMMAND(ID_COLOR_YELLOW, OnColorYellow)
- ON_UPDATE_COMMAND_UI(ID_COLOR_YELLOW, OnUpdateColorYellow)
- //}}AFX_MSG_MAP
- // Standard file based document commands
- ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
- ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
- END_MESSAGE_MAP()
-
- /////////////////////////////////////////////////////////////////////////////
- // CMiniDrawApp construction
-
- CMiniDrawApp::CMiniDrawApp()
- {
- // TODO: add construction code here,
- // Place all significant initialization in InitInstance
-
- m_CurrentColor = RGB (0,0,0);
- m_CurrentThickness = 1;
- m_CurrentTool = ID_TOOLS_LINE;
- m_IdxColorCmd = ID_COLOR_BLACK;
- }
-
- /////////////////////////////////////////////////////////////////////////////
- // The one and only CMiniDrawApp object
-
- CMiniDrawApp theApp;
-
- /////////////////////////////////////////////////////////////////////////////
- // CMiniDrawApp initialization
-
- BOOL CMiniDrawApp::InitInstance()
- {
- // Standard initialization
- // If you are not using these features and wish to reduce the size
- // of your final executable, you should remove from the following
- // the specific initialization routines you do not need.
-
- #ifdef _AFXDLL
- Enable3dControls(); // Call this when using MFC in a shared DLL
- #else
- Enable3dControlsStatic(); // Call this when linking to MFC statically
- #endif
-
- LoadStdProfileSettings(); // Load standard INI file options (including MRU)
-
- // Register the application's document templates. Document templates
- // serve as the connection between documents, frame windows and views.
-
- CSingleDocTemplate* pDocTemplate;
- pDocTemplate = new CSingleDocTemplate(
- IDR_MAINFRAME,
- RUNTIME_CLASS(CMiniDrawDoc),
- RUNTIME_CLASS(CMainFrame), // main SDI frame window
- RUNTIME_CLASS(CMiniDrawView));
- AddDocTemplate(pDocTemplate);
-
- EnableShellOpen ();
- RegisterShellFileTypes ();
-
- // Parse command line for standard shell commands, DDE, file open
- CCommandLineInfo cmdInfo;
- ParseCommandLine(cmdInfo);
-
- // Dispatch commands specified on the command line
- if (!ProcessShellCommand(cmdInfo))
- return FALSE;
-
- m_pMainWnd->DragAcceptFiles ();
-
- return TRUE;
- }
-
- /////////////////////////////////////////////////////////////////////////////
- // CAboutDlg dialog used for App About
-
- class CAboutDlg : public CDialog
- {
- public:
- CAboutDlg();
-
- // Dialog Data
- //{{AFX_DATA(CAboutDlg)
- enum { IDD = IDD_ABOUTBOX };
- //}}AFX_DATA
-
- // ClassWizard generated virtual function overrides
- //{{AFX_VIRTUAL(CAboutDlg)
- protected:
- virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
- //}}AFX_VIRTUAL
-
- // Implementation
- protected:
- //{{AFX_MSG(CAboutDlg)
- // No message handlers
- //}}AFX_MSG
- DECLARE_MESSAGE_MAP()
- };
-
- CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
- {
- //{{AFX_DATA_INIT(CAboutDlg)
- //}}AFX_DATA_INIT
- }
-
- void CAboutDlg::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CAboutDlg)
- //}}AFX_DATA_MAP
- }
-
- BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
- //{{AFX_MSG_MAP(CAboutDlg)
- // No message handlers
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
-
- // App command to run the dialog
- void CMiniDrawApp::OnAppAbout()
- {
- CAboutDlg aboutDlg;
- aboutDlg.DoModal();
- }
-
- /////////////////////////////////////////////////////////////////////////////
- // CMiniDrawApp commands
-
- void CMiniDrawApp::OnLineDouble()
- {
- // TODO: Add your command handler code here
- m_CurrentThickness = 2;
- }
-
- void CMiniDrawApp::OnUpdateLineDouble(CCmdUI* pCmdUI)
- {
- // TODO: Add your command update UI handler code here
- pCmdUI->SetCheck (m_CurrentThickness == 2 ? 1 : 0);
- }
-
- void CMiniDrawApp::OnLineSingle()
- {
- // TODO: Add your command handler code here
- m_CurrentThickness = 1;
- }
-
- void CMiniDrawApp::OnUpdateLineSingle(CCmdUI* pCmdUI)
- {
- // TODO: Add your command update UI handler code here
- pCmdUI->SetCheck (m_CurrentThickness == 1 ? 1 : 0);
- }
-
- void CMiniDrawApp::OnLineTriple()
- {
- // TODO: Add your command handler code here
- m_CurrentThickness = 3;
- }
-
- void CMiniDrawApp::OnUpdateLineTriple(CCmdUI* pCmdUI)
- {
- // TODO: Add your command update UI handler code here
- pCmdUI->SetCheck (m_CurrentThickness == 3 ? 1 : 0);
- }
-
- void CMiniDrawApp::OnToolsCircle()
- {
- // TODO: Add your command handler code here
- m_CurrentTool = ID_TOOLS_CIRCLE;
- }
-
- void CMiniDrawApp::OnUpdateToolsCircle(CCmdUI* pCmdUI)
- {
- // TODO: Add your command update UI handler code here
- pCmdUI->SetCheck (m_CurrentTool == ID_TOOLS_CIRCLE ? 1 : 0);
- }
-
- void CMiniDrawApp::OnToolsCirclefill()
- {
- // TODO: Add your command handler code here
- m_CurrentTool = ID_TOOLS_CIRCLEFILL;
- }
-
- void CMiniDrawApp::OnUpdateToolsCirclefill(CCmdUI* pCmdUI)
- {
- // TODO: Add your command update UI handler code here
- pCmdUI->SetCheck (m_CurrentTool == ID_TOOLS_CIRCLEFILL ? 1 : 0);
- }
-
- void CMiniDrawApp::OnToolsLine()
- {
- // TODO: Add your command handler code here
- m_CurrentTool = ID_TOOLS_LINE;
- }
-
- void CMiniDrawApp::OnUpdateToolsLine(CCmdUI* pCmdUI)
- {
- // TODO: Add your command update UI handler code here
- pCmdUI->SetCheck (m_CurrentTool == ID_TOOLS_LINE ? 1 : 0);
- }
-
- void CMiniDrawApp::OnToolsRectangle()
- {
- // TODO: Add your command handler code here
- m_CurrentTool = ID_TOOLS_RECTANGLE;
- }
-
- void CMiniDrawApp::OnUpdateToolsRectangle(CCmdUI* pCmdUI)
- {
- // TODO: Add your command update UI handler code here
- pCmdUI->SetCheck (m_CurrentTool == ID_TOOLS_RECTANGLE ? 1 : 0);
- }
-
- void CMiniDrawApp::OnToolsRectfill()
- {
- // TODO: Add your command handler code here
- m_CurrentTool = ID_TOOLS_RECTFILL;
- }
-
- void CMiniDrawApp::OnUpdateToolsRectfill(CCmdUI* pCmdUI)
- {
- // TODO: Add your command update UI handler code here
- pCmdUI->SetCheck (m_CurrentTool == ID_TOOLS_RECTFILL ? 1 : 0);
- }
-
- void CMiniDrawApp::OnToolsRectround()
- {
- // TODO: Add your command handler code here
- m_CurrentTool = ID_TOOLS_RECTROUND;
- }
-
- void CMiniDrawApp::OnUpdateToolsRectround(CCmdUI* pCmdUI)
- {
- // TODO: Add your command update UI handler code here
- pCmdUI->SetCheck (m_CurrentTool == ID_TOOLS_RECTROUND ? 1 : 0);
- }
-
- void CMiniDrawApp::OnToolsRectroundfill()
- {
- // TODO: Add your command handler code here
- m_CurrentTool = ID_TOOLS_RECTROUNDFILL;
- }
-
- void CMiniDrawApp::OnUpdateToolsRectroundfill(CCmdUI* pCmdUI)
- {
- // TODO: Add your command update UI handler code here
- pCmdUI->SetCheck (m_CurrentTool == ID_TOOLS_RECTROUNDFILL ? 1 : 0);
- }
-
- void CMiniDrawApp::OnColorBlack()
- {
- // TODO: Add your command handler code here
- m_CurrentColor = RGB (0,0,0);
- m_IdxColorCmd = ID_COLOR_BLACK;
- }
-
- void CMiniDrawApp::OnUpdateColorBlack(CCmdUI* pCmdUI)
- {
- // TODO: Add your command update UI handler code here
- pCmdUI->SetCheck (m_IdxColorCmd == ID_COLOR_BLACK ? 1 : 0);
- }
-
- void CMiniDrawApp::OnColorBlue()
- {
- // TODO: Add your command handler code here
- m_CurrentColor = RGB (0,0,255);
- m_IdxColorCmd = ID_COLOR_BLUE;
- }
-
- void CMiniDrawApp::OnUpdateColorBlue(CCmdUI* pCmdUI)
- {
- // TODO: Add your command update UI handler code here
- pCmdUI->SetCheck (m_IdxColorCmd == ID_COLOR_BLUE ? 1 : 0);
- }
-
- void CMiniDrawApp::OnColorCustom()
- {
- // TODO: Add your command handler code here
- CColorDialog ColorDialog;
-
- if (ColorDialog.DoModal () == IDOK)
- {
- m_CurrentColor = ColorDialog.GetColor ();
- m_IdxColorCmd = ID_COLOR_CUSTOM;
- }
- }
-
- void CMiniDrawApp::OnUpdateColorCustom(CCmdUI* pCmdUI)
- {
- // TODO: Add your command update UI handler code here
- pCmdUI->SetCheck (m_IdxColorCmd == ID_COLOR_CUSTOM ? 1 : 0);
- }
-
- void CMiniDrawApp::OnColorCyan()
- {
- // TODO: Add your command handler code here
- m_CurrentColor = RGB (0,255,255);
- m_IdxColorCmd = ID_COLOR_CYAN;
- }
-
- void CMiniDrawApp::OnUpdateColorCyan(CCmdUI* pCmdUI)
- {
- // TODO: Add your command update UI handler code here
- pCmdUI->SetCheck (m_IdxColorCmd == ID_COLOR_CYAN ? 1 : 0);
- }
-
- void CMiniDrawApp::OnColorGreen()
- {
- // TODO: Add your command handler code here
- m_CurrentColor = RGB (0,255,0);
- m_IdxColorCmd = ID_COLOR_GREEN;
- }
-
- void CMiniDrawApp::OnUpdateColorGreen(CCmdUI* pCmdUI)
- {
- // TODO: Add your command update UI handler code here
- pCmdUI->SetCheck (m_IdxColorCmd == ID_COLOR_GREEN ? 1 : 0);
- }
-
- void CMiniDrawApp::OnColorMagenta()
- {
- // TODO: Add your command handler code here
- m_CurrentColor = RGB (255,0,255);
- m_IdxColorCmd = ID_COLOR_MAGENTA;
- }
-
- void CMiniDrawApp::OnUpdateColorMagenta(CCmdUI* pCmdUI)
- {
- // TODO: Add your command update UI handler code here
- pCmdUI->SetCheck (m_IdxColorCmd == ID_COLOR_MAGENTA ? 1 : 0);
- }
-
- void CMiniDrawApp::OnColorRed()
- {
- // TODO: Add your command handler code here
- m_CurrentColor = RGB (255,0,0);
- m_IdxColorCmd = ID_COLOR_RED;
- }
-
- void CMiniDrawApp::OnUpdateColorRed(CCmdUI* pCmdUI)
- {
- // TODO: Add your command update UI handler code here
- pCmdUI->SetCheck (m_IdxColorCmd == ID_COLOR_RED ? 1 : 0);
- }
-
- void CMiniDrawApp::OnColorWhite()
- {
- // TODO: Add your command handler code here
- m_CurrentColor = RGB (255,255,255);
- m_IdxColorCmd = ID_COLOR_WHITE;
- }
-
- void CMiniDrawApp::OnUpdateColorWhite(CCmdUI* pCmdUI)
- {
- // TODO: Add your command update UI handler code here
- pCmdUI->SetCheck (m_IdxColorCmd == ID_COLOR_WHITE ? 1 : 0);
- }
-
- void CMiniDrawApp::OnColorYellow()
- {
- // TODO: Add your command handler code here
- m_CurrentColor = RGB (255,255,0);
- m_IdxColorCmd = ID_COLOR_YELLOW;
- }
-
- void CMiniDrawApp::OnUpdateColorYellow(CCmdUI* pCmdUI)
- {
- // TODO: Add your command update UI handler code here
- pCmdUI->SetCheck (m_IdxColorCmd == ID_COLOR_YELLOW ? 1 : 0);
- }
-