ac3e89aad892ed71448c62714e241e2c8025b9c2
[matches/honours.git] / research / transmission_spectroscopy / TOF / Win32++ / samples / Dock / src / Mainfrm.cpp
1 ////////////////////////////////////////////////////\r
2 // Mainfrm.cpp\r
3 \r
4 \r
5 #include "stdafx.h"\r
6 #include "mainfrm.h"\r
7 #include "resource.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++\\Dock"));\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 \r
34         switch(LOWORD(wParam))\r
35         {\r
36         case IDM_FILE_EXIT:\r
37                 // End the application\r
38                 ::PostMessage(m_hWnd, WM_CLOSE, 0, 0);\r
39                 return TRUE;\r
40         case IDM_DOCK_DEFAULT:\r
41                 SetRedraw(FALSE);       // Suppress drawing to the frame window\r
42                 m_DockView.CloseAllDockers();\r
43                 LoadDefaultDockers();\r
44                 SetRedraw(TRUE);        // Re-enable drawing to the frame window\r
45                 RedrawWindow(0, 0, RDW_INVALIDATE|RDW_FRAME|RDW_UPDATENOW|RDW_ALLCHILDREN);\r
46                 return TRUE;\r
47         case IDM_DOCK_CLOSEALL:\r
48                 m_DockView.CloseAllDockers();\r
49                 return TRUE;\r
50         case IDW_VIEW_STATUSBAR:\r
51                 OnViewStatusBar();\r
52                 return TRUE;\r
53         case IDW_VIEW_TOOLBAR:\r
54                 OnViewToolBar();\r
55                 return TRUE;\r
56         case IDM_HELP_ABOUT:\r
57                 // Display the help dialog\r
58                 OnHelp();\r
59                 return TRUE;\r
60         }\r
61 \r
62         return FALSE;\r
63 }\r
64 \r
65 void CMainFrame::OnCreate()\r
66 {\r
67         // OnCreate controls the way the frame is created.\r
68         // Overriding CFrame::Oncreate is optional.\r
69         // The default for the following variables is TRUE\r
70 \r
71         // m_bShowIndicatorStatus = FALSE;      // Don't show statusbar indicators\r
72         // m_bShowMenuStatus = FALSE;           // Don't show toolbar or menu status\r
73         // m_bUseReBar = FALSE;                         // Don't use rebars\r
74         // m_bUseThemes = FALSE;            // Don't use themes\r
75         // m_bUseToolBar = FALSE;                       // Don't use a toolbar\r
76 \r
77         // call the base class function\r
78         CFrame::OnCreate();\r
79 }\r
80 \r
81 void CMainFrame::OnInitialUpdate()\r
82 {\r
83         m_DockView.SetDockStyle(DS_CLIENTEDGE);\r
84 \r
85         // Load dock settings\r
86         if (!m_DockView.LoadRegistrySettings(GetRegistryKeyName()))\r
87                 LoadDefaultDockers();\r
88 \r
89         // PreCreate initially set the window as invisible, so show it now.\r
90         ShowWindow();\r
91 }\r
92 \r
93 void CMainFrame::LoadDefaultDockers()\r
94 {\r
95         // Note: The  DockIDs are used for saving/restoring the dockers state in the registry\r
96 \r
97         DWORD dwStyle = DS_CLIENTEDGE; // The style added to each docker\r
98 \r
99         CDocker* pDockLeft   = m_DockView.AddDockedChild(new CDockClasses, DS_DOCKED_LEFT | dwStyle, 200, ID_DOCK_CLASSES1);\r
100         CDocker* pDockRight  = m_DockView.AddDockedChild(new CDockClasses, DS_DOCKED_RIGHT | dwStyle, 200, ID_DOCK_CLASSES2);\r
101         CDocker* pDockTop    = m_DockView.AddDockedChild(new CDockText, DS_DOCKED_TOP | dwStyle, 100, ID_DOCK_TEXT1);\r
102         CDocker* pDockBottom = m_DockView.AddDockedChild(new CDockText, DS_DOCKED_BOTTOM | dwStyle, 100, ID_DOCK_TEXT2);\r
103 \r
104         pDockLeft->AddDockedChild(new CDockFiles, DS_DOCKED_BOTTOM | dwStyle, 150, ID_DOCK_FILES1);\r
105         pDockRight->AddDockedChild(new CDockFiles, DS_DOCKED_BOTTOM | dwStyle, 150, ID_DOCK_FILES2);\r
106         pDockTop->AddDockedChild(new CDockSimple, DS_DOCKED_RIGHT | dwStyle, 100, ID_DOCK_SIMPLE1);\r
107         pDockBottom->AddDockedChild(new CDockSimple, DS_DOCKED_RIGHT | dwStyle, 100, ID_DOCK_SIMPLE2);\r
108 }\r
109 \r
110 void CMainFrame::PreCreate(CREATESTRUCT &cs)\r
111 {\r
112         // Call the base class function first\r
113         CFrame::PreCreate(cs);\r
114         \r
115         // Hide the window initially by removing the WS_VISIBLE style\r
116         cs.style &= ~WS_VISIBLE;\r
117 }\r
118 \r
119 BOOL CMainFrame::SaveRegistrySettings()\r
120 {\r
121         if (CFrame::SaveRegistrySettings())\r
122                 return m_DockView.SaveRegistrySettings(GetRegistryKeyName());\r
123         else\r
124                 return FALSE;\r
125 }\r
126 \r
127 void CMainFrame::SetupToolBar()\r
128 {\r
129         // Set the Resource IDs for the toolbar buttons\r
130         AddToolBarButton( IDM_FILE_NEW,   FALSE );\r
131         AddToolBarButton( IDM_FILE_OPEN,  FALSE );\r
132         AddToolBarButton( IDM_FILE_SAVE,  FALSE );\r
133         \r
134         AddToolBarButton( 0 );  // Separator\r
135         AddToolBarButton( IDM_EDIT_CUT,   FALSE );\r
136         AddToolBarButton( IDM_EDIT_COPY,  FALSE );\r
137         AddToolBarButton( IDM_EDIT_PASTE, FALSE );\r
138         \r
139         AddToolBarButton( 0 );  // Separator\r
140         AddToolBarButton( IDM_FILE_PRINT, FALSE );\r
141         \r
142         AddToolBarButton( 0 );  // Separator\r
143         AddToolBarButton( IDM_HELP_ABOUT );\r
144 }\r

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