X-Git-Url: https://git.ucc.asn.au/?p=matches%2Fhonours.git;a=blobdiff_plain;f=research%2Ftransmission_spectroscopy%2FTOF%2FWin32%2B%2B%2Fsamples%2FDock%2Fsrc%2FMainfrm.cpp;fp=research%2Ftransmission_spectroscopy%2FTOF%2FWin32%2B%2B%2Fsamples%2FDock%2Fsrc%2FMainfrm.cpp;h=ac3e89aad892ed71448c62714e241e2c8025b9c2;hp=0000000000000000000000000000000000000000;hb=70a96cca12cb006506461d26cd112bab179fe74c;hpb=8caf60af39689a3546074f0c68d14c3a2e28191e diff --git a/research/transmission_spectroscopy/TOF/Win32++/samples/Dock/src/Mainfrm.cpp b/research/transmission_spectroscopy/TOF/Win32++/samples/Dock/src/Mainfrm.cpp new file mode 100644 index 00000000..ac3e89aa --- /dev/null +++ b/research/transmission_spectroscopy/TOF/Win32++/samples/Dock/src/Mainfrm.cpp @@ -0,0 +1,144 @@ +//////////////////////////////////////////////////// +// Mainfrm.cpp + + +#include "stdafx.h" +#include "mainfrm.h" +#include "resource.h" + + +// Definitions for the CMainFrame class +CMainFrame::CMainFrame() +{ + // Constructor for CMainFrame. Its called after CFrame's constructor + + //Set m_DockView as the view window of the frame + SetView(m_DockView); + + // Set the registry key name, and load the initial window position + // Use a registry key name like "CompanyName\\Application" + LoadRegistrySettings(_T("Win32++\\Dock")); +} + +CMainFrame::~CMainFrame() +{ + // Destructor for CMainFrame. +} + +BOOL CMainFrame::OnCommand(WPARAM wParam, LPARAM lParam) +{ + UNREFERENCED_PARAMETER(lParam); + + // OnCommand responds to menu and and toolbar input + + switch(LOWORD(wParam)) + { + case IDM_FILE_EXIT: + // End the application + ::PostMessage(m_hWnd, WM_CLOSE, 0, 0); + return TRUE; + case IDM_DOCK_DEFAULT: + SetRedraw(FALSE); // Suppress drawing to the frame window + m_DockView.CloseAllDockers(); + LoadDefaultDockers(); + SetRedraw(TRUE); // Re-enable drawing to the frame window + RedrawWindow(0, 0, RDW_INVALIDATE|RDW_FRAME|RDW_UPDATENOW|RDW_ALLCHILDREN); + return TRUE; + case IDM_DOCK_CLOSEALL: + m_DockView.CloseAllDockers(); + return TRUE; + case IDW_VIEW_STATUSBAR: + OnViewStatusBar(); + return TRUE; + case IDW_VIEW_TOOLBAR: + OnViewToolBar(); + return TRUE; + case IDM_HELP_ABOUT: + // Display the help dialog + OnHelp(); + return TRUE; + } + + return FALSE; +} + +void CMainFrame::OnCreate() +{ + // OnCreate controls the way the frame is created. + // Overriding CFrame::Oncreate is optional. + // The default for the following variables is TRUE + + // m_bShowIndicatorStatus = FALSE; // Don't show statusbar indicators + // m_bShowMenuStatus = FALSE; // Don't show toolbar or menu status + // m_bUseReBar = FALSE; // Don't use rebars + // m_bUseThemes = FALSE; // Don't use themes + // m_bUseToolBar = FALSE; // Don't use a toolbar + + // call the base class function + CFrame::OnCreate(); +} + +void CMainFrame::OnInitialUpdate() +{ + m_DockView.SetDockStyle(DS_CLIENTEDGE); + + // Load dock settings + if (!m_DockView.LoadRegistrySettings(GetRegistryKeyName())) + LoadDefaultDockers(); + + // PreCreate initially set the window as invisible, so show it now. + ShowWindow(); +} + +void CMainFrame::LoadDefaultDockers() +{ + // Note: The DockIDs are used for saving/restoring the dockers state in the registry + + DWORD dwStyle = DS_CLIENTEDGE; // The style added to each docker + + CDocker* pDockLeft = m_DockView.AddDockedChild(new CDockClasses, DS_DOCKED_LEFT | dwStyle, 200, ID_DOCK_CLASSES1); + CDocker* pDockRight = m_DockView.AddDockedChild(new CDockClasses, DS_DOCKED_RIGHT | dwStyle, 200, ID_DOCK_CLASSES2); + CDocker* pDockTop = m_DockView.AddDockedChild(new CDockText, DS_DOCKED_TOP | dwStyle, 100, ID_DOCK_TEXT1); + CDocker* pDockBottom = m_DockView.AddDockedChild(new CDockText, DS_DOCKED_BOTTOM | dwStyle, 100, ID_DOCK_TEXT2); + + pDockLeft->AddDockedChild(new CDockFiles, DS_DOCKED_BOTTOM | dwStyle, 150, ID_DOCK_FILES1); + pDockRight->AddDockedChild(new CDockFiles, DS_DOCKED_BOTTOM | dwStyle, 150, ID_DOCK_FILES2); + pDockTop->AddDockedChild(new CDockSimple, DS_DOCKED_RIGHT | dwStyle, 100, ID_DOCK_SIMPLE1); + pDockBottom->AddDockedChild(new CDockSimple, DS_DOCKED_RIGHT | dwStyle, 100, ID_DOCK_SIMPLE2); +} + +void CMainFrame::PreCreate(CREATESTRUCT &cs) +{ + // Call the base class function first + CFrame::PreCreate(cs); + + // Hide the window initially by removing the WS_VISIBLE style + cs.style &= ~WS_VISIBLE; +} + +BOOL CMainFrame::SaveRegistrySettings() +{ + if (CFrame::SaveRegistrySettings()) + return m_DockView.SaveRegistrySettings(GetRegistryKeyName()); + else + return FALSE; +} + +void CMainFrame::SetupToolBar() +{ + // Set the Resource IDs for the toolbar buttons + AddToolBarButton( IDM_FILE_NEW, FALSE ); + AddToolBarButton( IDM_FILE_OPEN, FALSE ); + AddToolBarButton( IDM_FILE_SAVE, FALSE ); + + AddToolBarButton( 0 ); // Separator + AddToolBarButton( IDM_EDIT_CUT, FALSE ); + AddToolBarButton( IDM_EDIT_COPY, FALSE ); + AddToolBarButton( IDM_EDIT_PASTE, FALSE ); + + AddToolBarButton( 0 ); // Separator + AddToolBarButton( IDM_FILE_PRINT, FALSE ); + + AddToolBarButton( 0 ); // Separator + AddToolBarButton( IDM_HELP_ABOUT ); +}