Commit before breaking everything
[matches/honours.git] / research / transmission_spectroscopy / TOF / Win32++ / tutorials / Tutorial8 / Mainfrm.cpp
1 ////////////////////////////////////////////////////\r
2 // Mainfrm.cpp  - definitions for the CMainFrame class\r
3 \r
4 #include "mainfrm.h"\r
5 #include "resource.h"\r
6 \r
7 \r
8 CMainFrame::CMainFrame()\r
9 {\r
10         // Set m_View as the view window of the frame\r
11         SetView(m_View);\r
12 }\r
13 \r
14 CMainFrame::~CMainFrame()\r
15 {\r
16 }\r
17 \r
18 BOOL CMainFrame::OnCommand(WPARAM wParam, LPARAM lParam)\r
19 {\r
20         // Process the messages from the Menu and Tool Bar\r
21         switch (LOWORD(wParam))\r
22         {\r
23         case IDM_FILE_NEW:\r
24                 m_View.ClearPoints();\r
25                 m_PathName = _T("");\r
26                 return TRUE;\r
27         case IDM_FILE_OPEN:\r
28                 OnFileOpen();\r
29                 return TRUE;\r
30         case IDM_FILE_SAVE:\r
31                 OnFileSave();\r
32                 return TRUE;\r
33         case IDM_FILE_SAVEAS:\r
34                 OnFileSaveAs();\r
35                 return TRUE;\r
36         case IDM_FILE_PRINT:\r
37                 ::MessageBox(NULL, _T("File Print Implemented Later"), _T("Menu"), MB_OK);\r
38                 return TRUE;\r
39         case IDM_PEN_RED:\r
40                 m_View.SetPen(RGB(255,0,0));\r
41                 return TRUE;\r
42         case IDM_PEN_BLUE:\r
43                 m_View.SetPen(RGB(0,0,255));\r
44                 return TRUE;\r
45         case IDM_PEN_GREEN:\r
46                 m_View.SetPen(RGB(0,196,0));\r
47                 return TRUE;\r
48         case IDM_PEN_BLACK:\r
49                 m_View.SetPen(RGB(0,0,0));\r
50                 return TRUE;\r
51         case IDM_HELP_ABOUT:\r
52                 OnHelp();\r
53                 return TRUE;\r
54         case IDM_FILE_EXIT:\r
55                 ::PostMessage(m_hWnd, WM_CLOSE, 0, 0);\r
56                 return TRUE;\r
57         }\r
58 \r
59         return FALSE;\r
60 }\r
61 \r
62 void CMainFrame::OnFileOpen()\r
63 {\r
64         CFile File;\r
65         CString str = File.OpenFileDialog(0, OFN_FILEMUSTEXIST, _T("Scribble Files (*.dat)\0*.dat\0\0"), this);\r
66 \r
67         if (!str.IsEmpty())\r
68         {\r
69                 // Retrieve the PlotPoint data\r
70                 if (m_View.FileOpen(str))\r
71                 {\r
72                         // Save the filename\r
73                         m_PathName = str;\r
74                         AddMRUEntry(str);\r
75                 }\r
76                 else\r
77                         m_PathName=_T("");\r
78         }\r
79 }\r
80 \r
81 void CMainFrame::OnFileSave()\r
82 {\r
83         if (m_PathName == _T(""))\r
84                 OnFileSaveAs();\r
85         else\r
86                 m_View.FileSave(m_PathName);\r
87 }\r
88 \r
89 void CMainFrame::OnFileSaveAs()\r
90 {\r
91         CFile File;\r
92         CString str = File.SaveFileDialog(0, OFN_OVERWRITEPROMPT, _T("Scribble Files (*.dat)\0*.dat\0\0"), _T("dat"), this);\r
93 \r
94         // Store the PlotPoint data in the file\r
95         if (!str.IsEmpty())\r
96         {\r
97                 m_PathName = str;\r
98 \r
99                 // Save the file name\r
100                 m_View.FileSave(str);\r
101                 AddMRUEntry(str);\r
102         }\r
103 }\r
104 \r
105 void CMainFrame::SetupToolBar()\r
106 {\r
107         // Set the Resource IDs for the toolbar buttons\r
108         AddToolBarButton( IDM_FILE_NEW   );\r
109         AddToolBarButton( IDM_FILE_OPEN  );\r
110         AddToolBarButton( IDM_FILE_SAVE  );\r
111         \r
112         AddToolBarButton( 0 );                          // Separator\r
113         AddToolBarButton( IDM_EDIT_CUT );\r
114         AddToolBarButton( IDM_EDIT_COPY );\r
115         AddToolBarButton( IDM_EDIT_PASTE );\r
116         \r
117         AddToolBarButton( 0 );                          // Separator\r
118         AddToolBarButton( IDM_FILE_PRINT );\r
119         \r
120         AddToolBarButton( 0 );                          // Separator\r
121         AddToolBarButton ( IDM_PEN_RED    );    \r
122         AddToolBarButton ( IDM_PEN_BLUE   );\r
123         AddToolBarButton ( IDM_PEN_GREEN  );\r
124         AddToolBarButton ( IDM_PEN_BLACK  );\r
125         AddToolBarButton ( IDM_HELP_ABOUT );\r
126 }\r
127 \r
128 LRESULT CMainFrame::WndProc(UINT uMsg, WPARAM wParam, LPARAM lParam)\r
129 {\r
130 //      switch (uMsg)\r
131 //      {\r
132 \r
133 //      } // switch (uMsg)\r
134 \r
135         return WndProcDefault(uMsg, wParam, lParam);\r
136 } // LRESULT CMainFrame::WndProc(...)\r
137 \r

UCC git Repository :: git.ucc.asn.au