--- /dev/null
+////////////////////////////////////////////////////\r
+// Mainfrm.cpp - definitions for the CMainFrame class\r
+\r
+#include "mainfrm.h"\r
+#include "resource.h"\r
+\r
+\r
+CMainFrame::CMainFrame()\r
+{\r
+ // Set m_View as the view window of the frame\r
+ SetView(m_View);\r
+}\r
+\r
+CMainFrame::~CMainFrame()\r
+{\r
+}\r
+\r
+BOOL CMainFrame::OnCommand(WPARAM wParam, LPARAM lParam)\r
+{\r
+ // Process the messages from the Menu and Tool Bar\r
+ switch (LOWORD(wParam))\r
+ {\r
+ case IDM_FILE_NEW:\r
+ m_View.ClearPoints();\r
+ m_PathName = _T("");\r
+ return TRUE;\r
+ case IDM_FILE_OPEN:\r
+ OnFileOpen();\r
+ return TRUE;\r
+ case IDM_FILE_SAVE:\r
+ OnFileSave();\r
+ return TRUE;\r
+ case IDM_FILE_SAVEAS:\r
+ OnFileSaveAs();\r
+ return TRUE;\r
+ case IDM_FILE_PRINT:\r
+ ::MessageBox(NULL, _T("File Print Implemented Later"), _T("Menu"), MB_OK);\r
+ return TRUE;\r
+ case IDM_PEN_RED:\r
+ m_View.SetPen(RGB(255,0,0));\r
+ return TRUE;\r
+ case IDM_PEN_BLUE:\r
+ m_View.SetPen(RGB(0,0,255));\r
+ return TRUE;\r
+ case IDM_PEN_GREEN:\r
+ m_View.SetPen(RGB(0,196,0));\r
+ return TRUE;\r
+ case IDM_PEN_BLACK:\r
+ m_View.SetPen(RGB(0,0,0));\r
+ return TRUE;\r
+ case IDM_HELP_ABOUT:\r
+ OnHelp();\r
+ return TRUE;\r
+ case IDM_FILE_EXIT:\r
+ ::PostMessage(m_hWnd, WM_CLOSE, 0, 0);\r
+ return TRUE;\r
+ }\r
+\r
+ return FALSE;\r
+}\r
+\r
+void CMainFrame::OnFileOpen()\r
+{\r
+ CFile File;\r
+ CString str = File.OpenFileDialog(0, OFN_FILEMUSTEXIST, _T("Scribble Files (*.dat)\0*.dat\0\0"), this);\r
+\r
+ if (!str.IsEmpty())\r
+ {\r
+ // Retrieve the PlotPoint data\r
+ if (m_View.FileOpen(str))\r
+ {\r
+ // Save the filename\r
+ m_PathName = str;\r
+ AddMRUEntry(str);\r
+ }\r
+ else\r
+ m_PathName=_T("");\r
+ }\r
+}\r
+\r
+void CMainFrame::OnFileSave()\r
+{\r
+ if (m_PathName == _T(""))\r
+ OnFileSaveAs();\r
+ else\r
+ m_View.FileSave(m_PathName);\r
+}\r
+\r
+void CMainFrame::OnFileSaveAs()\r
+{\r
+ CFile File;\r
+ CString str = File.SaveFileDialog(0, OFN_OVERWRITEPROMPT, _T("Scribble Files (*.dat)\0*.dat\0\0"), _T("dat"), this);\r
+\r
+ // Store the PlotPoint data in the file\r
+ if (!str.IsEmpty())\r
+ {\r
+ m_PathName = str;\r
+\r
+ // Save the file name\r
+ m_View.FileSave(str);\r
+ AddMRUEntry(str);\r
+ }\r
+}\r
+\r
+void CMainFrame::SetupToolBar()\r
+{\r
+ // Set the Resource IDs for the toolbar buttons\r
+ AddToolBarButton( IDM_FILE_NEW );\r
+ AddToolBarButton( IDM_FILE_OPEN );\r
+ AddToolBarButton( IDM_FILE_SAVE );\r
+ \r
+ AddToolBarButton( 0 ); // Separator\r
+ AddToolBarButton( IDM_EDIT_CUT );\r
+ AddToolBarButton( IDM_EDIT_COPY );\r
+ AddToolBarButton( IDM_EDIT_PASTE );\r
+ \r
+ AddToolBarButton( 0 ); // Separator\r
+ AddToolBarButton( IDM_FILE_PRINT );\r
+ \r
+ AddToolBarButton( 0 ); // Separator\r
+ AddToolBarButton ( IDM_PEN_RED ); \r
+ AddToolBarButton ( IDM_PEN_BLUE );\r
+ AddToolBarButton ( IDM_PEN_GREEN );\r
+ AddToolBarButton ( IDM_PEN_BLACK );\r
+ AddToolBarButton ( IDM_HELP_ABOUT );\r
+}\r
+\r
+LRESULT CMainFrame::WndProc(UINT uMsg, WPARAM wParam, LPARAM lParam)\r
+{\r
+// switch (uMsg)\r
+// {\r
+\r
+// } // switch (uMsg)\r
+\r
+ return WndProcDefault(uMsg, wParam, lParam);\r
+} // LRESULT CMainFrame::WndProc(...)\r
+\r