0023776: Redesign of MFC samples after V2d viewer removing
[occt.git] / samples / mfc / standard / Common / OCC_MainFrame.cpp
index 659d32c..246a9ed 100755 (executable)
@@ -35,100 +35,64 @@ static UINT indicators[] =
 
 OCC_MainFrame::OCC_MainFrame(BOOL withAISToolBar /*=false*/)
 {
-       m_withAISToolBar=withAISToolBar;
-       if(withAISToolBar){
-               m_AISToolBar = new CToolBar;
-       }
-       else
-               m_AISToolBar = NULL;
+  m_withAISToolBar=withAISToolBar;
+  if(withAISToolBar){
+    m_AISToolBar = new CToolBar;
+  }
+  else
+    m_AISToolBar = NULL;
 }
 
 OCC_MainFrame::~OCC_MainFrame()
 {
-       if (m_AISToolBar) delete m_AISToolBar;
+  if (m_AISToolBar) delete m_AISToolBar;
 }
 
-/*
-int FindMenuItem(CMenu* Menu, LPCTSTR MenuString)
-{
-   ASSERT(Menu);
-   ASSERT(::IsMenu(Menu->GetSafeHmenu()));
-
-   int count = Menu->GetMenuItemCount();
-   for (int i = 0; i < count; i++)
-   {
-      CString str;
-      if (Menu->GetMenuString(i, str, MF_BYPOSITION) &&
-         (strcmp(str, MenuString) == 0))
-         return i;
-   }
-
-   return -1;
-}
-*/
-
 int OCC_MainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
 {
-       if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1)
-               return -1;
-       
-       if (!m_wndToolBar.Create(this) ||
-                       !m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
-                       {
-                               TRACE0("Failed to create toolbar\n");
-                               return -1;      // fail to create
-                       }
-       
-       if (m_withAISToolBar){
-               if (!m_AISToolBar->Create(this) ||
-                               !m_AISToolBar->LoadToolBar(IDR_TB_AIS))
-                               {
-                                       TRACE0("Failed to create toolbar\n");
-                                       return -1;      // fail to create
-                               }
-       }
-       
-       if (!m_wndStatusBar.Create(this) ||
-               !m_wndStatusBar.SetIndicators(indicators,
-                 sizeof(indicators)/sizeof(UINT)))
-       {
-               TRACE0("Failed to create status bar\n");
-               return -1;      // fail to create
-       }
-
-       // TODO: Remove this if you don't want tool tips or a resizeable toolbar
-       m_wndToolBar.SetBarStyle(m_wndToolBar.GetBarStyle() |
-               CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
-
-       // TODO: Delete these three lines if you don't want the toolbar to
-       //  be dockable
-       m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
-       EnableDocking(CBRS_ALIGN_ANY);
-    DockControlBar(&m_wndToolBar,AFX_IDW_DOCKBAR_TOP);
-       if (m_withAISToolBar){
-               m_AISToolBar->SetBarStyle(m_AISToolBar->GetBarStyle() |
-               CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
-               m_AISToolBar->EnableDocking(CBRS_ALIGN_ANY);
-               DockControlBarLeftOf(m_AISToolBar,&m_wndToolBar);
-       }
-
-/*
-       CMenu* menu = GetMenu();
-       CMenu* SubMenu = menu->GetSubMenu(2);
-       int pos = FindMenuItem(SubMenu, "&About SampleName...");
-       if (pos > -1)
-       {
-      UINT id = SubMenu->GetMenuItemID(pos);
-         LPCTSTR SampleName = ((OCC_BaseApp* )AfxGetApp())->GetSampleName();
-         char* str="";
-         strcpy(str,SampleName);
-         strcat(str,"...");
-         char* about = "About ";
-         strcat(about,str);
-      SubMenu->ModifyMenu(id, MF_BYCOMMAND, id, about);
+  if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1)
+    return -1;
+
+  if (!m_wndToolBar.Create(this) ||
+    !m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
+  {
+    TRACE0("Failed to create toolbar\n");
+    return -1;      // fail to create
+  }
+
+  if (m_withAISToolBar){
+    if (!m_AISToolBar->Create(this) ||
+      !m_AISToolBar->LoadToolBar(IDR_TB_AIS))
+    {
+      TRACE0("Failed to create toolbar\n");
+      return -1;      // fail to create
     }
-*/
-       return 0;
+  }
+
+  if (!m_wndStatusBar.Create(this) ||
+    !m_wndStatusBar.SetIndicators(indicators,
+    sizeof(indicators)/sizeof(UINT)))
+  {
+    TRACE0("Failed to create status bar\n");
+    return -1;      // fail to create
+  }
+
+  // TODO: Remove this if you don't want tool tips or a resizeable toolbar
+  m_wndToolBar.SetBarStyle(m_wndToolBar.GetBarStyle() |
+    CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
+
+  // TODO: Delete these three lines if you don't want the toolbar to
+  //  be dockable
+  m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
+  EnableDocking(CBRS_ALIGN_ANY);
+  DockControlBar(&m_wndToolBar,AFX_IDW_DOCKBAR_TOP);
+  if (m_withAISToolBar){
+    m_AISToolBar->SetBarStyle(m_AISToolBar->GetBarStyle() |
+      CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
+    m_AISToolBar->EnableDocking(CBRS_ALIGN_ANY);
+    DockControlBarLeftOf(m_AISToolBar,&m_wndToolBar);
+  }
+  return 0;
 }
 
 /////////////////////////////////////////////////////////////////////////////
@@ -137,50 +101,49 @@ int OCC_MainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
 #ifdef _DEBUG
 void OCC_MainFrame::AssertValid() const
 {
-       CMDIFrameWnd::AssertValid();
+  CMDIFrameWnd::AssertValid();
 }
 
 void OCC_MainFrame::Dump(CDumpContext& dc) const
 {
-       CMDIFrameWnd::Dump(dc);
+  CMDIFrameWnd::Dump(dc);
 }
 
 #endif //_DEBUG
 
 void OCC_MainFrame::SetStatusMessage(const CString & message)
 {
-       m_wndStatusBar.SetWindowText(message);
+  m_wndStatusBar.SetWindowText(message);
 }
 
 
 BOOL OCC_MainFrame::PreCreateWindow(CREATESTRUCT& cs)
 {
-       // TODO: Modify the Window class or styles here by modifying
-       //  the CREATESTRUCT cs
-
-       return CMDIFrameWnd::PreCreateWindow(cs);
+  // TODO: Modify the Window class or styles here by modifying
+  //  the CREATESTRUCT cs
+  return CMDIFrameWnd::PreCreateWindow(cs);
 }
 
 void OCC_MainFrame::DockControlBarLeftOf(CToolBar* Bar,CToolBar* LeftOf)
 {
-     CRect rect;
-     DWORD dw;
-     UINT n;
-
-     // get MFC to adjust the dimensions of all docked ToolBars
-     // so that GetWindowRect will be accurate
-     RecalcLayout();
-     LeftOf->GetWindowRect(&rect);
-     rect.OffsetRect(1,0);
-     dw=LeftOf->GetBarStyle();
-     n = 0;
-     n = (dw&CBRS_ALIGN_TOP) ? AFX_IDW_DOCKBAR_TOP : n;
-     n = (dw&CBRS_ALIGN_BOTTOM && n==0) ? AFX_IDW_DOCKBAR_BOTTOM : n;
-     n = (dw&CBRS_ALIGN_LEFT && n==0) ? AFX_IDW_DOCKBAR_LEFT : n;
-     n = (dw&CBRS_ALIGN_RIGHT && n==0) ? AFX_IDW_DOCKBAR_RIGHT : n;
-
-     // When we take the default parameters on rect, DockControlBar will dock
-     // each Toolbar on a seperate line.  By calculating a rectangle, we in effect
-     // are simulating a Toolbar being dragged to that location and docked.
-     DockControlBar(Bar,n,&rect);
+  CRect rect;
+  DWORD dw;
+  UINT n;
+
+  // get MFC to adjust the dimensions of all docked ToolBars
+  // so that GetWindowRect will be accurate
+  RecalcLayout();
+  LeftOf->GetWindowRect(&rect);
+  rect.OffsetRect(1,0);
+  dw=LeftOf->GetBarStyle();
+  n = 0;
+  n = (dw&CBRS_ALIGN_TOP) ? AFX_IDW_DOCKBAR_TOP : n;
+  n = (dw&CBRS_ALIGN_BOTTOM && n==0) ? AFX_IDW_DOCKBAR_BOTTOM : n;
+  n = (dw&CBRS_ALIGN_LEFT && n==0) ? AFX_IDW_DOCKBAR_LEFT : n;
+  n = (dw&CBRS_ALIGN_RIGHT && n==0) ? AFX_IDW_DOCKBAR_RIGHT : n;
+
+  // When we take the default parameters on rect, DockControlBar will dock
+  // each Toolbar on a seperate line.  By calculating a rectangle, we in effect
+  // are simulating a Toolbar being dragged to that location and docked.
+  DockControlBar(Bar,n,&rect);
 }