ARGH
[matches/honours.git] / research / transmission_spectroscopy / TOF / Win32++ / samples / DockContainer / src / Mainfrm.cpp
1 ////////////////////////////////////////////////////\r
2 // Mainfrm.cpp\r
3 \r
4 #include "stdafx.h"\r
5 #include "resource.h"\r
6 #include "ContainerApp.h"\r
7 #include "mainfrm.h"\r
8 \r
9 \r
10 // Definitions for the CMainFrame class\r
11 CMainFrame::CMainFrame()\r
12 {\r
13         // Constructor for CMainFrame. Its called after CFrame's constructor\r
14 \r
15         //Set m_DockView as the view window of the frame\r
16         SetView(m_DockView);\r
17 \r
18         // Set the registry key name, and load the initial window position\r
19         // Use a registry key name like "CompanyName\\Application"\r
20         LoadRegistrySettings(_T("Win32++\\DockContainer"));\r
21 }\r
22 \r
23 CMainFrame::~CMainFrame()\r
24 {\r
25         // Destructor for CMainFrame.\r
26 }\r
27 \r
28 BOOL CMainFrame::OnCommand(WPARAM wParam, LPARAM lParam)\r
29 {\r
30         UNREFERENCED_PARAMETER(lParam);\r
31 \r
32         // OnCommand responds to menu and and toolbar input\r
33         switch(LOWORD(wParam))\r
34         {\r
35         case IDM_FILE_EXIT:\r
36                 // End the application\r
37                 ::PostMessage(m_hWnd, WM_CLOSE, 0, 0);\r
38                 return TRUE;\r
39         case IDM_DOCK_DEFAULT:\r
40                 m_DockView.CloseAllDockers();\r
41                 LoadDefaultDockers();\r
42                 return TRUE;\r
43         case IDM_DOCK_CLOSEALL:\r
44                 m_DockView.CloseAllDockers();\r
45                 return TRUE;\r
46         case IDW_VIEW_STATUSBAR:\r
47                 OnViewStatusBar();\r
48                 return TRUE;\r
49         case IDW_VIEW_TOOLBAR:\r
50                 OnViewToolBar();\r
51                 return TRUE;\r
52         case IDM_HELP_ABOUT:\r
53                 // Display the help dialog\r
54                 OnHelp();\r
55                 return TRUE;\r
56         }\r
57 \r
58         return FALSE;\r
59 }\r
60 \r
61 void CMainFrame::OnCreate()\r
62 {\r
63         // OnCreate controls the way the frame is created.\r
64         // Overriding CFrame::Oncreate is optional.\r
65         // The default for the following variables is TRUE\r
66 \r
67         // m_bShowIndicatorStatus = FALSE;      // Don't show statusbar indicators\r
68         // m_bShowMenuStatus = FALSE;           // Don't show toolbar or menu status\r
69         // m_bUseReBar = FALSE;                         // Don't use rebars\r
70         // m_bUseThemes = FALSE;            // Don't use themes\r
71         // m_bUseToolBar = FALSE;                       // Don't use a toolbar\r
72 \r
73         // call the base class function\r
74         CFrame::OnCreate();\r
75 }\r
76 \r
77 void CMainFrame::OnInitialUpdate()\r
78 {\r
79         m_DockView.SetDockStyle(DS_CLIENTEDGE);\r
80 \r
81         // Load dock settings\r
82         if (!m_DockView.LoadRegistrySettings(GetRegistryKeyName()))\r
83                 LoadDefaultDockers();\r
84 \r
85         // PreCreate initially set the window as invisible, so show it now.\r
86         ShowWindow();\r
87 }\r
88 \r
89 void CMainFrame::LoadDefaultDockers()\r
90 {\r
91         // Note: The  DockIDs are used for saving/restoring the dockers state in the registry\r
92 \r
93         DWORD dwStyle = DS_CLIENTEDGE; // The style added to each docker\r
94         \r
95         // Add the parent dockers\r
96         CDocker* pDockRight  = m_DockView.AddDockedChild(new CDockClasses, DS_DOCKED_RIGHT | dwStyle, 200, ID_DOCK_CLASSES1);   \r
97         CDocker* pDockBottom = m_DockView.AddDockedChild(new CDockText, DS_DOCKED_BOTTOM | dwStyle, 100, ID_DOCK_TEXT1);\r
98 \r
99         // Add the remaining dockers\r
100         pDockRight->AddDockedChild(new CDockFiles, DS_DOCKED_CONTAINER | dwStyle, 200, ID_DOCK_FILES1);\r
101         pDockRight->AddDockedChild(new CDockClasses, DS_DOCKED_CONTAINER | dwStyle, 200, ID_DOCK_CLASSES2);\r
102         pDockRight->AddDockedChild(new CDockFiles, DS_DOCKED_CONTAINER | dwStyle, 200, ID_DOCK_FILES2);\r
103 \r
104         pDockBottom->AddDockedChild(new CDockOutput, DS_DOCKED_CONTAINER | dwStyle, 100, ID_DOCK_OUTPUT1);\r
105         pDockBottom->AddDockedChild(new CDockText, DS_DOCKED_CONTAINER | dwStyle, 100, ID_DOCK_TEXT2);\r
106         pDockBottom->AddDockedChild(new CDockOutput, DS_DOCKED_CONTAINER | dwStyle, 100, ID_DOCK_OUTPUT2);\r
107 }\r
108 \r
109 void CMainFrame::PreCreate(CREATESTRUCT &cs)\r
110 {\r
111         // Call the base class function first\r
112         CFrame::PreCreate(cs);\r
113         \r
114         // Hide the window initially by removing the WS_VISIBLE style\r
115         cs.style &= ~WS_VISIBLE;\r
116 }\r
117 \r
118 BOOL CMainFrame::SaveRegistrySettings()\r
119 {\r
120         if (CFrame::SaveRegistrySettings())\r
121                 return m_DockView.SaveRegistrySettings(GetRegistryKeyName());\r
122         else\r
123                 return FALSE;\r
124 }\r
125 \r
126 void CMainFrame::SetupToolBar()\r
127 {\r
128         // Set the Resource IDs for the toolbar buttons\r
129         AddToolBarButton( IDM_FILE_NEW,   FALSE );\r
130         AddToolBarButton( IDM_FILE_OPEN,  FALSE );\r
131         AddToolBarButton( IDM_FILE_SAVE,  FALSE );\r
132         \r
133         AddToolBarButton( 0 );  // Separator\r
134         AddToolBarButton( IDM_EDIT_CUT,   FALSE );\r
135         AddToolBarButton( IDM_EDIT_COPY,  FALSE );\r
136         AddToolBarButton( IDM_EDIT_PASTE, FALSE );\r
137         \r
138         AddToolBarButton( 0 );  // Separator\r
139         AddToolBarButton( IDM_FILE_PRINT, FALSE );\r
140         \r
141         AddToolBarButton( 0 );  // Separator\r
142         AddToolBarButton( IDM_HELP_ABOUT );\r
143 }\r

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