GME  13
MainFrm.cpp
Go to the documentation of this file.
00001 // MainFrm.cpp : implementation of the CMainFrame class
00002 //
00003 
00004 #include "stdafx.h"
00005 #include "GMEApp.h"
00006 
00007 #include "GMEstd.h"
00008 #include "MainFrm.h"
00009 #include "GMEDoc.h"
00010 #include "GMEChildFrame.h"
00011 #include "Splash.h"
00012 #include "GMEEventLogger.h"
00013 #include <sys/types.h>
00014 #include <sys/stat.h>
00015 #include "ChildFrm.h"
00016 #include "GMEView.h"
00017 
00018 #ifdef _DEBUG
00019 #define new DEBUG_NEW
00020 #undef THIS_FILE
00021 static char THIS_FILE[] = __FILE__;
00022 #endif
00023 
00025 // Tooltip helper for components
00026 
00027 afx_msg BOOL CComponentBar::OnTT(UINT, NMHDR * pNMHDR, LRESULT * ) {
00028         TOOLTIPTEXT *pTTT = (TOOLTIPTEXT *)pNMHDR;
00029         UINT_PTR nIndex =pNMHDR->idFrom;
00030 
00031         if(nIndex == 1)
00032         {
00033                 _tcsncpy(pTTT->szText, _T("Check constraints"), 79);
00034                 return FALSE;
00035         }
00036 
00037         if(nIndex == 2)
00038         {
00039                 _tcsncpy(pTTT->szText, _T("Interpret the current model"), 79);
00040                 return FALSE;
00041         }
00042 
00043 
00044         CMFCToolBarButton* pButton = GetButton(nIndex - 1);
00045         ASSERT(pButton);
00046         if (pButton) {
00047                 UINT nID = pButton->m_nID;
00048 
00049                 if(nID >= ID_FILE_RUNPLUGIN1 && nID <= ID_FILE_RUNPLUGIN_LAST) {
00050                         _tcsncpy(pTTT->szText, theApp.pluginTooltips[nID-ID_FILE_RUNPLUGIN1], 79);
00051                         return FALSE;
00052                 }
00053                 if(nID >= ID_FILE_INTERPRET1 && nID <= ID_FILE_INTERPRET_LAST) {
00054                         _tcsncpy(pTTT->szText, theApp.interpreterTooltips[nID-ID_FILE_INTERPRET1], 79);
00055                                 return FALSE;
00056                 }
00057         }
00058         return TRUE;
00059 }
00060 
00061 const int  iMaxUserToolbars = 10;
00062 const UINT uiFirstUserToolBarId = AFX_IDW_CONTROLBAR_FIRST + 40;
00063 const UINT uiLastUserToolBarId = uiFirstUserToolBarId + iMaxUserToolbars - 1;
00064 
00065 
00066 
00067 IMPLEMENT_DYNCREATE(CComponentBar, CMFCToolBar)
00068 
00069 BEGIN_MESSAGE_MAP(CComponentBar, CMFCToolBar)
00070         ON_NOTIFY_EX( TTN_NEEDTEXT, 0, OnTT )
00071 END_MESSAGE_MAP()
00072 
00073 
00075 // CMainFrame
00076 
00077 CMainFrame *CMainFrame::theInstance = 0;
00078 
00079 IMPLEMENT_DYNAMIC(CMainFrame, CMDIFrameWndEx)
00080 
00081 BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWndEx)
00082         ON_UPDATE_COMMAND_UI(ID_INDICATOR_TIME, OnUpdateTime)
00083         //{{AFX_MSG_MAP(CMainFrame)
00084         ON_WM_CREATE()
00085         ON_COMMAND(ID_EDIT_SEARCH, OnEditSearch)
00086         ON_UPDATE_COMMAND_UI(ID_EDIT_SEARCH, OnUpdateEditSearch)
00087         ON_UPDATE_COMMAND_UI(ID_WINDOW_NEW, OnUpdateWindowNew)
00088         ON_WM_TIMER()
00089         ON_WM_DESTROY()
00090         
00091         ON_COMMAND(ID_VIEW_REFRESH_SOURCECONTROL, OnViewMultiUserRefreshSourceControl)
00092         ON_UPDATE_COMMAND_UI(ID_VIEW_REFRESH_SOURCECONTROL, OnUpdateViewMultiUserRefreshSourceControl)
00093         ON_COMMAND(ID_MULTIUSER_ACTIVEUSERS, OnViewMultiUserActiveUsers)
00094         ON_UPDATE_COMMAND_UI(ID_MULTIUSER_ACTIVEUSERS, OnUpdateViewMultiUserActiveUsers)
00095         ON_COMMAND(ID_VIEW_CLEARCONSOLE, OnViewClearConsole)
00096         ON_UPDATE_COMMAND_UI(ID_VIEW_CLEARCONSOLE, OnUpdateViewClearConsole)
00097 
00098 #define MSG_MAP_VIEW_PANE(ID, class_, member) \
00099         ON_COMMAND(ID, (&CMainFrame::OnViewPane<class_, &CMainFrame::member>)) \
00100         ON_UPDATE_COMMAND_UI(ID, (&CMainFrame::OnUpdateViewPane<class_, &CMainFrame::member>))
00101         MSG_MAP_VIEW_PANE(ID_VIEW_GMEBROWSER,           CGMEBrowser,            m_browser)
00102         MSG_MAP_VIEW_PANE(ID_VIEW_OBJECTINSPECTOR,      CGMEObjectInspector,m_objectInspector)
00103         MSG_MAP_VIEW_PANE(ID_VIEW_PARTBROWSER,          CGMEPartBrowser,        m_partBrowser)
00104         MSG_MAP_VIEW_PANE(ID_VIEW_PANNWIN,                      CGMEPanningWindow,      m_panningWindow)
00105         MSG_MAP_VIEW_PANE(ID_VIEW_CONSOLE,                      CGMEConsole,            m_console)
00106         MSG_MAP_VIEW_PANE(ID_VIEW_GMEBROWSER,           CGMEBrowser,            m_browser)
00107         MSG_MAP_VIEW_PANE(ID_VIEW_SEARCH,                       CGMESearch,                     m_search)
00108         ON_WM_CLOSE()
00109         ON_WM_DROPFILES()
00110         ON_UPDATE_COMMAND_UI_RANGE(ID_VIEW_APPLOOK_WIN_2000, ID_VIEW_APPLOOK_OFF_2007_AQUA, &CMainFrame::OnUpdateApplicationLook)
00111         ON_COMMAND(ID_WINDOW_MANAGER, &CMainFrame::OnWindowManager)
00112         ON_COMMAND(ID_VIEW_CUSTOMIZE, &CMainFrame::OnViewCustomize)
00113         ON_COMMAND(ID_VIEW_FULLSCREEN, OnViewFullScreen)
00114         ON_REGISTERED_MESSAGE(AFX_WM_CREATETOOLBAR, OnToolbarCreateNew)
00115 //}}AFX_MSG_MAP
00116         // By making the Menu IDs that same as the ToolBar IDs
00117         // we can leverage off of code that is already provided
00118         // in MFCs implementation of CFrameWnd to check, uncheck
00119         // show and hide toolbars.
00120         ON_COMMAND_EX(IDW_TOOLBAR_MAIN, OnBarCheck)
00121         ON_COMMAND_EX(IDW_TOOLBAR_WINS, OnBarCheck)
00122         ON_COMMAND_EX(IDW_TOOLBAR_COMPONENT, OnBarCheck)
00123         ON_COMMAND_EX(IDW_TOOLBAR_MODE, OnBarCheck)
00124         ON_COMMAND_EX(IDW_TOOLBAR_NAVIG, OnBarCheck)
00125         ON_COMMAND_EX(IDW_TOOLBAR_MODELING, OnBarCheck)
00126         ON_UPDATE_COMMAND_UI(IDW_TOOLBAR_MAIN, OnUpdateControlBarMenus)
00127         ON_UPDATE_COMMAND_UI(IDW_TOOLBAR_WINS, OnUpdateControlBarMenus)
00128         ON_UPDATE_COMMAND_UI(IDW_TOOLBAR_COMPONENT, OnUpdateControlBarMenus)
00129         ON_UPDATE_COMMAND_UI(IDW_TOOLBAR_MODE, OnUpdateControlBarMenus)
00130         ON_UPDATE_COMMAND_UI(IDW_TOOLBAR_NAVIG, OnUpdateControlBarMenus)
00131         ON_UPDATE_COMMAND_UI(IDW_TOOLBAR_MODELING, OnUpdateControlBarMenus)
00132         ON_COMMAND(ID_BUTTON33020, OnBtnBack)
00133         ON_COMMAND(ID_BUTTON33022, OnBtnHome)
00134         ON_UPDATE_COMMAND_UI(ID_BUTTON33020, OnUpdateBtnBack)
00135         ON_UPDATE_COMMAND_UI(ID_BUTTON33022, OnUpdateBtnHome)
00136         ON_COMMAND(ID_WINDOW_NEWHORIZONTALTABGROUP, &CMainFrame::OnWindowNewhorizontaltabgroup)
00137         ON_COMMAND(ID_WINDOW_NEWVERTICALTABGROUP, &CMainFrame::OnWindowNewverticaltabgroup)
00138         ON_COMMAND(ID_WINDOW_MOVETOPREVIOUSTABGROUP, &CMainFrame::OnWindowMovetoprevioustabgroup)
00139         ON_COMMAND(ID_WINDOW_MOVETONEXTTABGROUP, &CMainFrame::OnWindowMovetonexttabgroup)
00140         ON_UPDATE_COMMAND_UI(ID_WINDOW_NEWHORIZONTALTABGROUP, &CMainFrame::OnUpdateWindowNewhorizontaltabgroup)
00141         ON_UPDATE_COMMAND_UI(ID_WINDOW_NEWVERTICALTABGROUP, &CMainFrame::OnUpdateWindowNewverticaltabgroup)
00142         ON_UPDATE_COMMAND_UI(ID_WINDOW_MOVETOPREVIOUSTABGROUP, &CMainFrame::OnUpdateWindowMovetoprevioustabgroup)
00143         ON_UPDATE_COMMAND_UI(ID_WINDOW_MOVETONEXTTABGROUP, &CMainFrame::OnUpdateWindowMovetonexttabgroup)
00144         ON_REGISTERED_MESSAGE(AFX_WM_ON_GET_TAB_TOOLTIP, &CMainFrame::OnGetTabTooltip)
00145 END_MESSAGE_MAP()
00146 
00147 static UINT indicators[] =
00148 {
00149         ID_SEPARATOR,           // status line indicator
00150         ID_INDICATOR_CAPS,
00151         ID_INDICATOR_NUM,
00152         ID_INDICATOR_SCRL,
00153 };
00154 
00155 class CGMEMDIClientAreaWnd : public CMDIClientAreaWnd
00156 {
00157         virtual CMFCTabCtrl* CreateTabGroup(CMFCTabCtrl* pWndTab)
00158         {
00159                 pWndTab = new CGMEMFCTabCtrl;
00160                 return __super::CreateTabGroup(pWndTab);
00161         }
00162 };
00163 
00164 CMainFrame::CMainFrame()
00165 {
00166         theInstance = this;     
00167         m_autosaveTimerID = NULL;
00168         theApp.m_nAppLook = theApp.GetInt(_T("ApplicationLook"), ID_VIEW_APPLOOK_VS_2005);
00169 #ifdef new
00170 #pragma push_macro("new")
00171 #undef new
00172         new ((void*)&m_wndClientArea) CGMEMDIClientAreaWnd();
00173 #pragma pop_macro("new")
00174 #else
00175         new ((void*)&m_wndClientArea) CGMEMDIClientAreaWnd();
00176 #endif
00177 }
00178 
00179 CMainFrame::~CMainFrame()
00180 {
00181         theInstance = 0;        
00182 }
00183 
00184 void CMainFrame::setGmeOleApp( CGMEOLEApp * the_ole_app)
00185 {
00186         mGmeOleApp = the_ole_app;
00187 
00188         IDispatch *disp;                                                        // REFCOUNT is initially 1 ( ONE )
00189 
00190         disp = mGmeOleApp->GetIDispatch(FALSE); // do not increment the refcount
00191 
00192         m_console.SetGMEApp(disp); // increments the refcount to 2 (since it stores the value in a smart pointer)
00193 
00194         // decrement the refcount, relying on the other components maintaining the correct refcounts
00195         //this line is needed either in setGmeOleApp or here
00196         // ULONG ul = mGmeOleApp->GetIDispatch(FALSE)->Release();
00197         //ul = mGmeOleApp->GetIDispatch(FALSE)->Release(); //decrement the refcount to 1
00198 
00199         // later when a project is opened the "mGmeOleApp" will be registered as a client of the "MgaProject", thus
00200         // it will be incremented once again the refcount
00201         
00202         // when the project is closed, then the CGMEApp::CloseProject will erase this reference to the "mGmeOleApp"  with a  "mgaClient = NULL;" call
00203 
00204         // so the Mga component is referencing the GmeOleApp by its MgaProject's client member
00205         //        Console compt is referencing the GmeOleApp by its member
00206         //
00207         // beware that when the main GME would like to destruct the Console upon exiting
00208         // then the Console has to be the last referring to the GmeOleApp, so that it 
00209         // can be released
00210 }
00211 
00212 void CMainFrame::setMgaProj()
00213 {
00214         IDispatch *disp;
00215 
00216         disp = mGmeOleApp->GetIDispatch(FALSE); // do not increment the refcount
00217 
00218         m_console.SetGMEProj(disp);
00219 }
00220 
00221 void CMainFrame::clearGmeOleApp()
00222 {
00223         m_console.SetGMEProj( 0 );
00224         m_console.SetGMEApp( 0 );
00225 
00226         //this line is needed either in setGmeOleApp or here
00227         mGmeOleApp->GetIDispatch(FALSE)->Release();
00228 
00229         // make sure
00230         mGmeOleApp = 0;
00231 }
00232 
00233 void CMainFrame::clearMgaProj()
00234 {
00235         m_console.SetGMEProj( 0 );
00236 }
00237 
00238 
00239 void CMainFrame::OnClose()
00240 {
00241         if (theApp.SaveAllModified())
00242         {
00243 #ifdef _DEBUG
00244                 clearGmeOleApp();
00245                 CMDIFrameWndEx::OnClose();
00246 #else
00247                 // n.b. this saves pane positions
00248                 CMDIFrameWndEx::OnClose();
00249                 // n.b. C# interpreters may not Release() IGMEOLEApp, which keeps us ::Run()ing forever
00250                 // TerminateProcess will be unpleasant for DCOM (but the user asked for it)
00251                 TerminateProcess(GetCurrentProcess(), 0);
00252 #endif
00253         }
00254 }
00255 
00256 int CMainFrame::CreateToolBars()
00257 {
00258         
00259         // 3 separate TOOLBARs are created
00260         //#define AFX_IDW_CONTROLBAR_FIRST        0xE800 = 59392
00261         //#define AFX_IDW_CONTROLBAR_LAST         0xE8FF
00262         //
00263         //#define AFX_IDW_TOOLBAR                 0xE800  // main Toolbar for window
00264         //#define AFX_IDW_STATUS_BAR              0xE801  // Status bar window
00265         //#define AFX_IDW_PREVIEW_BAR             0xE802  // PrintPreview Dialog Bar
00266         //#define AFX_IDW_RESIZE_BAR              0xE803  // OLE in-place resize bar
00267         //#define AFX_IDW_REBAR                   0xE804  // COMCTL32 "rebar" Bar
00268         //#define AFX_IDW_DIALOGBAR               0xE805  // CDialogBar
00269         //#define AFX_IDW_DOCKBAR_TOP             0xE81B
00270         //#define AFX_IDW_DOCKBAR_LEFT            0xE81C
00271         //#define AFX_IDW_DOCKBAR_RIGHT           0xE81D
00272         //#define AFX_IDW_DOCKBAR_BOTTOM          0xE81E
00273         //#define AFX_IDW_DOCKBAR_FLOAT           0xE81F = 59423
00274 
00275         // thus the IDW_TOOLBAR_* ids conform to these limits
00276         // being assigned numbers from 0xE820
00277 
00278 
00279         // Checking resolution
00280         CWindowDC dc(NULL);
00281         bool bHiColorIcons = dc.GetDeviceCaps(BITSPIXEL) >= 16;
00282 
00283 
00284         // -- MAIN ToolBar
00285         if( !m_wndToolBarMain.CreateEx( this
00286                 , TBSTYLE_FLAT
00287                 , WS_CHILD | WS_VISIBLE | CBRS_ALIGN_TOP
00288                 , CRect(0,0,0,0)
00289                 , IDW_TOOLBAR_MAIN) // provide unqiue ID for each toolbar [important !!!]
00290                 ||
00291                 !m_wndToolBarMain.LoadToolBar(IDR_TOOLBAR_MAIN, 0, 0, FALSE, 0, 0, bHiColorIcons ? IDB_MAIN_TOOLBAR24 : 0)
00292                 )
00293         {
00294                 TRACE(_T("Failed to create main toolbar\n"));
00295                 return -1;      // fail to create
00296         }
00297 
00298         m_wndToolBarMain.SetPaneStyle(m_wndToolBarMain.GetPaneStyle()
00299                 | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
00300 
00301         m_wndToolBarMain.EnableCustomizeButton(TRUE, ID_VIEW_CUSTOMIZE, _T("Customize..."));
00302 
00303         // Enable toolbar and docking window menu replacement
00304         EnablePaneMenu(TRUE, ID_VIEW_CUSTOMIZE, _T("Customize..."), ID_VIEW_TOOLBAR, FALSE, TRUE);
00305 
00306 
00307         // -- Modeling ToolBar
00308         if( !m_wndToolBarModeling.CreateEx( this
00309                 , TBSTYLE_FLAT
00310                 , WS_CHILD |  WS_VISIBLE | CBRS_ALIGN_TOP
00311                 , CRect(0,0,0,0)
00312                 , IDW_TOOLBAR_MODELING) // provide unqiue ID for each toolbar [important !!!]
00313                 ||
00314                 !m_wndToolBarModeling.LoadToolBar(IDR_TOOLBAR_MODELING, 0, 0, FALSE, 0, 0, bHiColorIcons ? IDB_MODELING_TOOLBAR24 : 0)
00315                 )
00316         {
00317                 TRACE(_T("Failed to create modeling toolbar\n"));
00318                 return -1;      // fail to create
00319         }
00320 
00321         m_wndToolBarModeling.SetPaneStyle( m_wndToolBarModeling.GetPaneStyle()
00322                 | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
00323 
00324         m_wndToolBarModeling.EnableCustomizeButton(TRUE, ID_VIEW_CUSTOMIZE, _T("Customize..."));
00325 
00326         // -- Window Arrangement ToolBar
00327         if( !m_wndToolBarWins.CreateEx( this
00328                 , TBSTYLE_FLAT
00329                 , WS_CHILD |  WS_VISIBLE | CBRS_ALIGN_TOP
00330                 , CRect(0,0,0,0)
00331                 , IDW_TOOLBAR_WINS) // provide unqiue ID for each toolbar
00332                 ||
00333                 !m_wndToolBarWins.LoadToolBar(IDR_TOOLBAR_WINS, 0, 0, FALSE, 0, 0, bHiColorIcons ? IDB_WINS_TOOLBAR24 : 0)
00334                 )
00335         {
00336                 TRACE0("Failed to create windows toolbar\n");
00337                 return -1;
00338         }
00339 
00340         m_wndToolBarWins.SetPaneStyle( m_wndToolBarWins.GetPaneStyle()
00341                 | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
00342 
00343         m_wndToolBarWins.EnableCustomizeButton(TRUE, ID_VIEW_CUSTOMIZE, _T("Customize..."));
00344 
00345         // -- User-defined Component ToolBar
00346         if( !m_wndComponentBar.CreateEx( this
00347                 , TBSTYLE_FLAT
00348                 , WS_CHILD | WS_VISIBLE | CBRS_ALIGN_TOP
00349                 , CRect(0, 0, 0, 0)
00350                 , IDW_TOOLBAR_COMPONENT) // provide unqiue ID for each toolbar
00351                 ||
00352                 !m_wndComponentBar.LoadToolBar(IDR_TOOLBAR_COMPONENTS, 0, 0, TRUE, 0, 0, bHiColorIcons ? IDB_COMPONENTS_TOOLBAR24 : 0)
00353                 )
00354         {
00355                 TRACE0("Failed to create component toolbar\n");
00356                 return -1;      // fail to create
00357         }
00358         m_wndComponentBar.SetPaneStyle(m_wndComponentBar.GetPaneStyle()
00359                 | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
00360 
00361 
00362         // Mode toolbar
00363 
00364         if( !m_wndModeBar.CreateEx( this
00365                 , TBSTYLE_FLAT
00366                 , WS_CHILD | WS_VISIBLE | CBRS_ALIGN_TOP
00367                 , CRect(0, 0, 0, 0)
00368                 , IDW_TOOLBAR_MODE)     // provide unqiue ID for each toolbar [important !!!] 
00369                                                         // see MainFrm.cpp OnCreate for other details
00370                 ||
00371                 !m_wndModeBar.LoadToolBar(IDR_TOOLBAR_MODE, 0, 0, FALSE, 0, 0, bHiColorIcons ? IDB_MODE_TOOLBAR24 : 0)
00372                 )
00373         {
00374                 TRACE0("Failed to create mode toolbar\n");
00375                 return -1;      // fail to create
00376         }
00377         m_wndModeBar.SetPaneStyle(m_wndModeBar.GetPaneStyle() 
00378                 | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
00379 
00380 
00381         // Navigation toolbar
00382         if( !m_wndNaviBar.CreateEx( this
00383                 , TBSTYLE_FLAT
00384                 , WS_CHILD | WS_VISIBLE | CBRS_ALIGN_TOP
00385                 , CRect(0, 0, 0, 0)
00386                 , IDW_TOOLBAR_NAVIG) // unique!
00387                 ||
00388                 !m_wndNaviBar.LoadToolBar(IDR_TOOLBAR_NAVIG, 0, 0, FALSE, 0, 0, bHiColorIcons ? IDB_NAVIG_TOOLBAR24 : 0)
00389                 )
00390         {
00391                 TRACE0("Failed to create m_wndNaviBar toolbar\n");
00392                 return -1;      // fail to create
00393         }
00394         m_wndNaviBar.SetPaneStyle(m_wndNaviBar.GetPaneStyle()
00395                 | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
00396 
00397 
00398 
00399         // --- Docking ---
00400         // Toolbars are dockable to any side of the frame
00401         m_wndToolBarMain.SetWindowText(_T("Standard"));
00402         m_wndToolBarMain.EnableDocking(CBRS_ALIGN_ANY);
00403 
00404         m_wndToolBarModeling.SetWindowText(_T("Modeling"));
00405         m_wndToolBarModeling.EnableDocking(CBRS_ALIGN_ANY);
00406 
00407         m_wndToolBarWins.SetWindowText(_T("Windows"));
00408         m_wndToolBarWins.EnableDocking(CBRS_ALIGN_ANY);
00409 
00410         m_wndComponentBar.SetWindowText(_T("Components"));
00411         m_wndComponentBar.EnableDocking(CBRS_ALIGN_ANY);
00412         m_wndComponentBar.AdjustSizeImmediate(TRUE);
00413 
00414         m_wndModeBar.SetWindowText(_T("Mode")); // will show this title when floating
00415         m_wndModeBar.EnableDocking(CBRS_ALIGN_ANY);
00416 
00417         m_wndNaviBar.SetWindowText(_T("Navigator")); // will show this title when floating
00418         m_wndNaviBar.EnableDocking(CBRS_ALIGN_ANY);
00419 
00420         // Because of "DockPaneLeftOf" we dock them in "reverse" order: the rightmost first
00421         DockPane(&m_wndComponentBar, AFX_IDW_DOCKBAR_TOP);
00422         DockPaneLeftOf(&m_wndToolBarWins, &m_wndComponentBar);
00423         DockPaneLeftOf(&m_wndToolBarModeling, &m_wndToolBarWins);
00424         DockPaneLeftOf(&m_wndToolBarMain, &m_wndToolBarModeling);
00425 
00426         DockPane(&m_wndNaviBar, AFX_IDW_DOCKBAR_LEFT);
00427         DockPaneLeftOf(&m_wndModeBar, &m_wndNaviBar);   // This means actually "TopOf" instead of "LeftOf", because they are vetical
00428 
00429         // Hide navigation and mode panels first, they are visible when a model is open
00430         ShowNavigationAndModeToolbars(false);
00431 
00432         // Allow user-defined toolbars operations:
00433         InitUserToolbars(NULL, uiFirstUserToolBarId, uiLastUserToolBarId);
00434 
00435         return 0;
00436 }
00437 
00438 
00439 int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
00440 {
00441         if (CMDIFrameWndEx::OnCreate(lpCreateStruct) == -1)
00442                 return -1;
00443 
00444         // Creating tabs for the MDI Children (documents)
00445         CMDITabInfo mdiTabParams;
00446         mdiTabParams.m_style = CMFCTabCtrl::STYLE_3D_VS2005;    // other styles available...
00447         mdiTabParams.m_bActiveTabCloseButton = TRUE;                    // set to FALSE to place close button at right of tab area
00448         mdiTabParams.m_bTabIcons = FALSE;                                               // set to TRUE to enable document icons on MDI tabs
00449         mdiTabParams.m_bAutoColor = TRUE;                                               // set to FALSE to disable auto-coloring of MDI tabs
00450         mdiTabParams.m_bDocumentMenu = TRUE;                                    // enable the document menu at the right edge of the tab area
00451         mdiTabParams.m_bEnableTabSwap = TRUE;                                   // enable the user to change the tabs positions by dragging the tabs
00452         mdiTabParams.m_bFlatFrame = TRUE;                                               // give each tab window has a flat frame
00453         mdiTabParams.m_bTabCloseButton = FALSE;                                 // enable each tab window to display the Close button on the right edge of the tab.
00454         mdiTabParams.m_bTabCustomTooltips = TRUE;                               // enable the tabs to display tooltips.
00455         mdiTabParams.m_tabLocation = CMFCTabCtrl::LOCATION_TOP; // Specifies that the tabs labels are located at the top of the page
00456         EnableMDITabbedGroups(TRUE, mdiTabParams);
00457 
00458         CMFCToolBar::EnableQuickCustomization();
00459 
00460         // Set the visual manager and style based on persisted value
00461         OnApplicationLook(theApp.m_nAppLook);
00462 
00463         EnableDocking(CBRS_ALIGN_ANY);
00464 
00465 
00466 
00467         // STATUS BAR
00468         if (!m_wndStatusBar.Create(this) ||
00469                 !m_wndStatusBar.SetIndicators(indicators,
00470                 sizeof(indicators)/sizeof(UINT)))
00471         {
00472                 TRACE0("Failed to create status bar\n");
00473                 return -1;              // fail to create
00474         }
00475 
00476         CMFCToolBar::EnableQuickCustomization();
00477 
00478         // MENU BAR
00479         if (!m_wndMenuBar.Create(this))
00480         {
00481                 TRACE0("Failed to create menubar\n");
00482                 return -1;              // fail to create
00483         }
00484 
00485         m_wndMenuBar.SetPaneStyle(m_wndMenuBar.GetPaneStyle() | CBRS_SIZE_DYNAMIC | CBRS_TOOLTIPS | CBRS_FLYBY);
00486         m_wndMenuBar.EnableDocking(CBRS_ALIGN_TOP);
00487         DockPane(&m_wndMenuBar, AFX_IDW_DOCKBAR_TOP);
00488         
00489         // prevent the menu bar from taking the focus on activation
00490         CMFCPopupMenu::SetForceMenuFocus(FALSE);
00491 
00492         // TOOLBARS
00493         if(CreateToolBars())
00494         {
00495                 return -1;
00496         }
00497 
00498 
00499         // Enable enhanced windows management dialog
00500         EnableWindowsDialog(ID_WINDOW_MANAGER, _T("Model windows..."), TRUE);
00501 
00502 
00503 
00504 
00505         // enable Visual Studio 2005 style docking window behavior
00506         CDockingManager::SetDockingMode(DT_SMART);
00507         CMDIFrameWndEx::EnableMDITabsLastActiveActivation(TRUE);
00508 
00509         // enable Visual Studio 2005 style docking window auto-hide behavior
00510 //      EnableAutoHidePanes(CBRS_ALIGN_ANY);
00511 
00512 
00513 
00514         // PART BROWSER
00515         if (!m_partBrowser.Create(_T("Part Browser"), this, CSize(240,480),
00516                 TRUE, ID_PARTBROWSER, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_LEFT| CBRS_FLOAT_MULTI))
00517         {
00518                         TRACE0("Failed to create part browser\n");
00519                         return -1;      // fail to create
00520         }
00521         m_partBrowser.EnableDocking(CBRS_ALIGN_ANY);
00522         int captionHeight = m_partBrowser.GetCaptionHeight();
00523         m_partBrowser.SetMinSize(CSize(captionHeight, captionHeight));
00524 
00525         // PANNING WINDOW
00526         if (!m_panningWindow.Create(_T("Panning Window"), this, CSize(240, 160),
00527                 TRUE, ID_PANNWIN, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_LEFT | CBRS_FLOAT_MULTI))
00528         {
00529                 TRACE0("Failed to create panning Window\n");
00530                 return -1;              // fail to create
00531         }       
00532         m_panningWindow.EnableDocking(CBRS_ALIGN_ANY);
00533         m_panningWindow.SetMinSize(CSize(captionHeight, captionHeight));
00534 
00535         // GME ACTIVE BROWSER TREE
00536         if (!m_browser.Create(_T("GME Browser"), this, CSize(240, 80),
00537                 TRUE, ID_GMEBROWSER, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_RIGHT | CBRS_FLOAT_MULTI))
00538         {
00539                 TRACE0("Failed to create browser\n");
00540                 return -1;              // fail to create
00541         }
00542         m_browser.EnableDocking(CBRS_ALIGN_ANY);
00543         m_browser.SetMinSize(CSize(captionHeight, captionHeight));
00544 
00545         // OBJECT INSPECTOR
00546         if(!m_objectInspector.Create(_T("Object Inspector"), this, CSize(240, 160),
00547                 TRUE, IDD_OBJECT_INSPECTOR_DIALOG, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_RIGHT | CBRS_FLOAT_MULTI))
00548         {
00549                 TRACE0("Failed to create Object Inspector\n");
00550                 return -1;              // fail to create
00551         }
00552         m_objectInspector.EnableDocking(CBRS_ALIGN_ANY);
00553         m_objectInspector.SetMinSize(CSize(captionHeight, captionHeight));
00554 
00555         // CONSOLE
00556         if(!m_console.Create(_T("Console"), this, CSize(80, 160),
00557                 TRUE, IDD_CONSOLE_DIALOG, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_BOTTOM | CBRS_FLOAT_MULTI))
00558         {
00559                 TRACE0("Failed to create Console\n");
00560                 return -1;              // fail to create
00561         }
00562         m_console.EnableDocking(CBRS_ALIGN_ANY);
00563         m_console.SetMinSize(CSize(captionHeight, captionHeight));
00564 
00565         // SEARCH - Modal Dialog
00566         if(!m_search.Create(_T("Search"), this, CSize(200, 200),
00567                 TRUE, IDD_SEARCH_DIALOG, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_RIGHT | CBRS_FLOAT_MULTI))
00568         {
00569                 TRACE0("Failed to create Search Control\n");
00570                 return -1;              // fail to create
00571         }
00572         m_search.EnableDocking(CBRS_ALIGN_ANY);
00573         m_search.SetMinSize(CSize(captionHeight, captionHeight));
00574 
00575 
00576         // --- Docking ---
00577 
00578         DockPane(&m_browser, AFX_IDW_DOCKBAR_RIGHT);
00579 
00580         DockPane(&m_partBrowser, AFX_IDW_DOCKBAR_LEFT);
00581 
00582         m_panningWindow.DockToWindow(&m_partBrowser, CBRS_ALIGN_BOTTOM);
00583 
00584         m_objectInspector.DockToWindow(&m_browser,CBRS_ALIGN_BOTTOM);
00585 
00586         DockPane(&m_console,AFX_IDW_DOCKBAR_BOTTOM);
00587 
00588         CDockablePane* pTabbedBar = NULL;
00589         m_search.AttachToTabWnd(&m_console, DM_SHOW, TRUE, &pTabbedBar);
00590 
00591         m_search.ShowPane(FALSE, FALSE, FALSE); 
00592 
00593 
00594         // CG: The following block was inserted by 'Status Bar' component.
00595         {
00596                 // Find out the size of the static variable 'indicators' defined
00597                 // by AppWizard and copy it
00598                 int nOrigSize = sizeof(indicators) / sizeof(UINT);
00599 
00600                 UINT pIndicators[16];
00601                 memcpy(pIndicators, indicators, sizeof(indicators));
00602 
00603                 // Call the Status Bar Component's status bar creation function
00604                 if (!InitStatusBar(pIndicators, nOrigSize, 60))
00605                 {
00606                         TRACE0("Failed to initialize Status Bar\n");
00607                         return -1;
00608                 }
00609         }
00610 
00611         // hide initially, openProject will show it if components available
00612         // thus we ignore the registry settings
00613         m_wndComponentBar.ShowWindow(SW_HIDE);
00614         ShowPane(&m_wndComponentBar, FALSE, FALSE, FALSE);
00615 
00616 
00617         // CG: The following line was added by the Splash Screen component.
00618         CSplashWnd::ShowSplashScreen(this);
00619 
00620         // Adding full screen functionality
00621         EnableFullScreenMode(ID_VIEW_FULLSCREEN);
00622 
00623         return 0;
00624 }
00625 
00626 BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
00627 {
00628         if( !CMDIFrameWndEx::PreCreateWindow(cs) )
00629                 return FALSE;
00630         // TODO: Modify the Window class or styles here by modifying
00631         //  the CREATESTRUCT cs
00632 
00633         return TRUE;
00634 }
00635 
00637 // CMainFrame diagnostics
00638 
00639 #ifdef _DEBUG
00640 void CMainFrame::AssertValid() const
00641 {
00642         CMDIFrameWndEx::AssertValid();
00643 }
00644 
00645 void CMainFrame::Dump(CDumpContext& dc) const
00646 {
00647         CMDIFrameWndEx::Dump(dc);
00648 }
00649 
00650 #endif //_DEBUG
00651 
00652 void CMainFrame::UpdateTitle(LPCTSTR title)
00653 {
00654         UpdateFrameTitleForDocument(title);
00655 }
00656 
00657 void CMainFrame::DestroyView(CView *view)
00658 {
00659         ASSERT(view);
00660         CFrameWnd *frame = view->GetParentFrame();
00661         ASSERT(frame);
00662         frame->DestroyWindow();
00663 }
00664 
00665 void CMainFrame::ActivateView(CView *view)
00666 {
00667         ActivateFrame();
00668         ASSERT(view);
00669         CFrameWnd *frame = view->GetParentFrame();
00670         ASSERT(frame);
00671         CFrameWnd *activeFrame = GetActiveFrame();
00672         ASSERT(activeFrame);
00673         if(frame != activeFrame)
00674                 frame->ActivateFrame(frame->IsIconic() ? SW_SHOWNORMAL : -1);
00675 }
00676 
00677 struct AccessProtectedKludge : public CMDIClientAreaWnd 
00678 {
00679         CObList& get()
00680         {
00681                 return m_lstRemovedTabbedGroups;
00682         }
00683         static CObList& get(CMDIClientAreaWnd& clientarea)
00684         {
00685                 return ((AccessProtectedKludge*)(&clientarea))->get();
00686         }
00687 };
00688 
00689 void CMainFrame::CreateNewView(CView *view, CComPtr<IMgaModel>& model)
00690 {
00691         CMultiDocTemplate *docTemplate = theApp.pDocTemplate;
00692         if(view != 0) {
00693                 ActivateView(view);
00694         }
00695         else {
00696                 CDocument *pDocument = CGMEDoc::theInstance;
00697                 ASSERT( pDocument );
00698 
00699                 // KMS: WM_MDIACTIVATE is sent 3 times for tabs after the first: once for the new CChildFrame, once for the old,
00700                 // and again for the new. Disable panning window refresh, since it can be expensive.
00701                 CGMEView* oldGmeview = CGMEView::GetActiveView();
00702                 if (oldGmeview)
00703                         oldGmeview->m_bEnablePannWindowRefresh = false;
00704                 CFrameWnd *pFrame = docTemplate->CreateNewFrame(pDocument, NULL);
00705                 if(pFrame == NULL) {
00706                         AfxMessageBox(_T("Failed to create window"),MB_OK | MB_ICONSTOP);
00707                         return;
00708                 }
00709                 docTemplate->InitialUpdateFrame(pFrame,pDocument);
00710                 HWND hwndActive = (HWND) m_wndClientArea.SendMessage(WM_MDIGETACTIVE);
00711 
00712                 m_wndClientArea.UpdateMDITabbedGroups(FALSE);  // The framework by default calls this via OnUpdateFrameTitle 
00713                                                               // (overloaded in our implementation without calling the base class intentionally)
00714 
00715                 // n.b. m_wndClientArea is long-lived, but puts closed tab groups in .m_lstRemovedTabbedGroups
00716                 // delete them here to prevent a resource leak
00717                 // FIXME: this should run when the last tab is closed
00718                 CObList& m_lstRemovedTabbedGroups = AccessProtectedKludge::get(m_wndClientArea);
00719                 while (!m_lstRemovedTabbedGroups.IsEmpty())
00720                 {
00721                         CMFCTabCtrl* pWnd= DYNAMIC_DOWNCAST(CMFCTabCtrl, m_lstRemovedTabbedGroups.RemoveTail());
00722                         if (pWnd != NULL)
00723                         {
00724                                 pWnd->DestroyWindow();
00725                                 delete pWnd;
00726                         }
00727                 }
00728 
00729                 CGMEView* newGmeview = CGMEView::GetActiveView();
00730 
00731                 if (oldGmeview)
00732                 {
00733                         oldGmeview->m_bEnablePannWindowRefresh = true;
00734                 }
00735                 newGmeview->m_bEnablePannWindowRefresh = true;
00736                 newGmeview->DoPannWinRefresh();
00737 
00738 #if defined(ACTIVEXGMEVIEW)
00739                 CMainFrame* pMainFrame = (CMainFrame*)theApp.m_pMainWnd;
00740                 // Get the active MDI child window.
00741                 CMDIChildWnd* pChild = (CMDIChildWnd*)pMainFrame->GetActiveFrame();
00742                 // or CMDIChildWnd *pChild = pFrame->MDIGetActive();
00743                 // Get the active view attached to the active MDI child window.
00744                 CGMEChildFrame* pView = (CGMEChildFrame*)pChild->GetActiveView();
00745                 pView->SetProject(theApp.mgaProject);
00746 
00747                 m_partBrowser.SetProject(theApp.mgaProject);
00748                 try {
00749                         long status;
00750                         COMTHROW(theApp.mgaProject->get_ProjectStatus(&status));
00751                         bool inTrans = (status & 0x08L) != 0;
00752                         CComPtr<IMgaTerritory> terr;
00753                         if (!inTrans) {
00754                                 COMTHROW(theApp.mgaProject->CreateTerritory(NULL, &terr));
00755                                 COMTHROW(theApp.mgaProject->BeginTransaction(terr, TRANSACTION_READ_ONLY));
00756                         } else {
00757                                 COMTHROW(theApp.mgaProject->get_ActiveTerritory(&terr));
00758                         }
00759 
00760                         CComPtr<IMgaFCO> modelFco;
00761                         COMTHROW(terr->OpenFCO(model, &modelFco));
00762                         CComQIPtr<IMgaModel> model2 = modelFco;
00763 
00764                         status = OBJECT_ZOMBIE;
00765                         COMTHROW(model2->get_Status(&status));
00766                         if (status == OBJECT_EXISTS) {
00767                                 CComPtr<IMgaMetaFCO> ccpMetaFCO;
00768                                 COMTHROW(model2->get_Meta(&ccpMetaFCO));
00769                                 CComQIPtr<IMgaMetaModel> metaModel = ccpMetaFCO;
00770                                 metaref_type metaid;
00771                                 COMTHROW(metaModel->get_MetaRef(&metaid));
00772                                 CGuiMetaModel* guiMeta = CGuiMetaProject::theInstance->GetGuiMetaModel(metaid);
00773                                 m_partBrowser.SetMetaModel(guiMeta);
00774                                 pView->SetMetaModel(guiMeta);
00775                                 pView->ChangeAspect(0);
00776                                 m_partBrowser.SetBgColor(RGB(0xFF, 0xFF, 0xFF));
00777                                 m_partBrowser.ChangeAspect(0);
00778                                 m_partBrowser.RePaint();
00779                         }
00780 
00781                         if (!inTrans) {
00782                                 theApp.mgaProject->CommitTransaction();
00783                         }
00784                 } catch(...) {
00785                         ASSERT(0);
00786                 }
00787                 pView->SetModel(model);
00788 #endif
00789         }
00790 }
00791 
00792 void CMainFrame::WriteStatusMode(const CString& txt)
00793 {
00794         WriteStatusText(modePaneNo,txt);
00795 }
00796 
00797 void CMainFrame::WriteStatusParadigm(const CString& txt)
00798 {
00799         WriteStatusText(paradigmPaneNo,txt);
00800 }
00801 
00802 void CMainFrame::WriteStatusZoom(int zoomPct)
00803 {
00804         CString txt;
00805         txt.Format(_T("%d%%"), zoomPct);
00806         WriteStatusText(zoomPaneNo,txt);
00807 }
00808 
00809 void CMainFrame::WriteStatusText(int pane, const CString& txt)
00810 {
00811         CSize size;
00812         {
00813                 HGDIOBJ hOldFont = NULL;
00814                 HFONT hFont = (HFONT)m_wndStatusBar.SendMessage(WM_GETFONT);
00815                 CClientDC dc(NULL);
00816                 if (hFont != NULL) 
00817                         hOldFont = dc.SelectObject(hFont);
00818                 size = dc.GetTextExtent(txt);
00819                 if (hOldFont != NULL) 
00820                         dc.SelectObject(hOldFont);
00821         }
00822         
00823         int lng;
00824         UINT nID,nStyle;
00825         m_wndStatusBar.GetPaneInfo(pane, nID, nStyle, lng);
00826         m_wndStatusBar.SetPaneInfo(pane, nID, nStyle, size.cx);
00827     m_wndStatusBar.SetPaneText(pane,txt);
00828 }
00829 
00831 // CMainFrame message handlers
00832 
00833 
00834 void CMainFrame::OnUpdateTime(CCmdUI* /*pCmdUI*/)
00835 {
00836         // CG: This function was inserted by 'Status Bar' component.
00837 
00838         // Get current date and format it
00839         CTime time = CTime::GetCurrentTime();
00840         CString strTime = time.Format(_T("%I:%M  "));
00841         strTime = (time.GetHour() < 12 ? _T("") : _T(""))+ strTime +(time.GetHour() < 12 ? _T("AM "):_T("PM "));
00842 
00843         WriteStatusText(timePaneNo,strTime);
00844 }
00845 
00846 BOOL CMainFrame::InitStatusBar(UINT *pIndicators, int nSize, int nSeconds)
00847 {
00848         modePaneNo = nSize++;
00849         pIndicators[modePaneNo] = ID_INDICATOR_MODE;
00850         zoomPaneNo = nSize++;
00851         pIndicators[zoomPaneNo] = ID_INDICATOR_ZOOM;
00852         paradigmPaneNo = nSize++;
00853         pIndicators[paradigmPaneNo] = ID_INDICATOR_PARADIGM;
00854         timePaneNo = nSize++;
00855         pIndicators[timePaneNo] = ID_INDICATOR_TIME;
00856 
00857         nSeconds = 10;
00858         m_wndStatusBar.SetTimer(0x1000, nSeconds * 1000, NULL);
00859 
00860         return m_wndStatusBar.SetIndicators(pIndicators, nSize);
00861 }
00862 
00863 
00864 void CMainFrame::OnEditSearch()
00865 {
00866         m_search.ShowPane(TRUE, FALSE, TRUE);
00867 /*      CRect searchWindowRect;
00868         m_search.GetWindowRect(&searchWindowRect);
00869         if (m_search.CanBeResized() && searchWindowRect.Height() <= searchWindowRect.GetCaptionHeight()) {
00870                 ScreenToClient(&searchWindowRect);
00871                 m_search.SetWindowPos(NULL, searchWindowRect.left, searchWindowRect.top, searchWindowRect.Width(), searchWindowRect.Height() + 100, SWP_NOZORDER | SWP_NOMOVE);
00872         }*/
00873 
00874         CComPtr<IMgaObjects> objs;
00875         if( CGMEBrowser::theInstance->GetSelectedItems( objs))
00876                 m_search.SetSelMgaObjects( objs);
00877         m_search.SetFocus(); // allows for easy 'Find Next' feature
00878         // the user might press ^F whenever she'd like to jump
00879         // to a focused searchbox
00880 }
00881 
00882 void CMainFrame::OnUpdateEditSearch(CCmdUI* pCmdUI)
00883 {
00884         pCmdUI->Enable(
00885                 (CGMEDoc::theInstance != 0) &&
00886                 m_search &&
00887                 1 //(!m_search.IsWindowVisible()) 
00888                 // from now on will allow multiple ^F-s, and as a result it 
00889                 // will set focus back to search window (like in VStudio).
00890                 // allows for easy 'Find Next'-like functionality
00891                 );
00892 }
00893 
00894 
00895 void CMainFrame::SetGMEViewMetaModel(CGuiMetaModel* meta)
00896 {
00897         CDocument* pDocument = CGMEDoc::theInstance;
00898         POSITION pos = pDocument->GetFirstViewPosition();
00899         if (pos) {
00900                 while (pos != NULL) {
00901 #if defined(ACTIVEXGMEVIEW)
00902                         CGMEChildFrame* pView = (CGMEChildFrame*) pDocument->GetNextView(pos);
00903                         pView->SetMetaModel(meta);
00904 #endif
00905                 }
00906         }
00907 }
00908 
00909 void CMainFrame::ChangeGMEViewAspect(int ind)
00910 {
00911         CDocument* pDocument = CGMEDoc::theInstance;
00912         POSITION pos = pDocument->GetFirstViewPosition();
00913         if (pos) {
00914                 while (pos != NULL) {
00915 #if defined(ACTIVEXGMEVIEW)
00916                         CGMEChildFrame* pView = (CGMEChildFrame*) pDocument->GetNextView(pos);
00917                         pView->ChangeAspect(ind);
00918 #endif
00919                 }
00920         }
00921 }
00922 
00923 void CMainFrame::CycleGMEViewAspect()
00924 {
00925         CDocument* pDocument = CGMEDoc::theInstance;
00926         POSITION pos = pDocument->GetFirstViewPosition();
00927         if (pos) {
00928                 while (pos != NULL) {
00929 #if defined(ACTIVEXGMEVIEW)
00930                         CGMEChildFrame* pView = (CGMEChildFrame*) pDocument->GetNextView(pos);
00931                         pView->CycleAspect();
00932 #endif
00933                 }
00934         }
00935 }
00936 
00937 void CMainFrame::GMEViewInvalidate()
00938 {
00939         CDocument* pDocument = CGMEDoc::theInstance;
00940         POSITION pos = pDocument->GetFirstViewPosition();
00941         if (pos) {
00942                 while (pos != NULL) {
00943 #if defined(ACTIVEXGMEVIEW)
00944                         CGMEChildFrame* pView = (CGMEChildFrame*) pDocument->GetNextView(pos);
00945                         pView->Invalidate();
00946 #endif
00947                 }
00948         }
00949 }
00950 
00951 
00952 // This function is Copyright (c) 2000, Cristi Posea.
00953 // See www.datamekanix.com for more control bars tips&tricks.
00954 BOOL CMainFrame::VerifyBarState(LPCTSTR lpszProfileName)
00955 {
00956     CDockState state;
00957     state.LoadState(lpszProfileName);
00958 
00959     for (int i = 0; i < state.m_arrBarInfo.GetSize(); i++)
00960     {
00961         CControlBarInfo* pInfo = (CControlBarInfo*)state.m_arrBarInfo[i];
00962         ASSERT(pInfo != NULL);
00963         int nDockedCount = pInfo->m_arrBarID.GetSize();
00964         if (nDockedCount > 0)
00965         {
00966             // dockbar
00967             for (int j = 0; j < nDockedCount; j++)
00968             {
00969                 UINT nID = (UINT) pInfo->m_arrBarID[j];
00970                 if (nID == 0) continue; // row separator
00971                 if (nID > 0xFFFF)
00972                     nID &= 0xFFFF; // placeholder - get the ID
00973                 if (GetControlBar(nID) == NULL)
00974                     return FALSE;
00975             }
00976         }
00977         
00978         if (!pInfo->m_bFloating) // floating dockbars can be created later
00979             if (GetControlBar(pInfo->m_nBarID) == NULL)
00980                 return FALSE; // invalid bar ID
00981     }
00982 
00983     return TRUE;
00984 }
00985 
00986 BOOL CMainFrame::DestroyWindow()
00987 {
00988         return CMDIFrameWndEx::DestroyWindow();
00989 }
00990 
00991 void CMainFrame::ShowObjectInspector()
00992 {
00993         ShowPane(&m_objectInspector, TRUE, FALSE, TRUE);
00994 }
00995 
00996 void CMainFrame::ShowFindDlg()
00997 {
00998         OnEditSearch();
00999 }
01000 
01001 void CMainFrame::HideFindDlg()
01002 {
01003         m_search.SetSelMgaObjects( CComPtr<IMgaObjects>( 0));
01004         m_search.ShowWindow( SW_HIDE);
01005 }
01006 
01007 void CMainFrame::OnTimer(UINT_PTR nIDEvent)
01008 {
01009         if (nIDEvent == GME_AUTOSAVE_EVENT_ID) {
01010                 theApp.Autosave();
01011         }
01012         
01013         CMDIFrameWndEx::OnTimer(nIDEvent);
01014 }
01015 
01016 
01017 void CMainFrame::StartAutosaveTimer(int secs)
01018 {
01019         StopAutosaveTimer();
01020         ASSERT(m_autosaveTimerID == NULL);
01021 
01022         m_autosaveTimerID = SetTimer(GME_AUTOSAVE_EVENT_ID, 1000 * secs, NULL);
01023 }
01024 
01025 void CMainFrame::StopAutosaveTimer()
01026 {
01027         if (m_autosaveTimerID) {
01028                 KillTimer(m_autosaveTimerID);
01029                 m_autosaveTimerID = NULL;
01030         }       
01031 }
01032 
01033 
01034 
01035 void CMainFrame::OnDestroy() 
01036 {
01037         CMDIFrameWndEx::OnDestroy();
01038         
01039         StopAutosaveTimer();
01040 }
01041 
01042 
01043 /*
01044 IMgaObject*     CMainFrame::folderFindByPath(IMgaFolder* folder, const wstring& strPath)
01045 {
01046         wstring strPath2;
01047         wstring strName;
01048         wstring::size_type iPos = strPath.find( L"/" );
01049         if ( iPos == wstring::npos ) 
01050         {
01051                 strName = strPath;
01052                 strPath2 = L"";
01053         }
01054         else {
01055                 if ( iPos == 0 )
01056                         strPath2 = strPath.substr( iPos + 1);
01057                 iPos = strPath2.find( L"/" );
01058                 if ( iPos == wstring::npos ) 
01059                 {
01060                         strName = strPath2;
01061                         strPath2 = L"";
01062 *               }
01063                 else 
01064                 {
01065                         strName = strPath2.substr( 0, iPos );
01066                         strPath2 = strPath2.substr( iPos );
01067                 }
01068         }
01069         COMTRY {
01070                 CComPtr<IMgaFolder> root;
01071                 if (!folder)
01072                 {
01073                         COMTHROW(theApp.mgaProject->get_RootFolder(&root));
01074                         if (!root)
01075                                 return NULL;
01076                         CComBSTR strname;
01077                         COMTHROW(root->get_Name(&strname));
01078                         if ( strName == (wstring)(WCHAR*)(BSTR)strname) 
01079                         {
01080                                 if ( strPath2.empty() )
01081                                 {
01082                                         CComPtr<IMgaObject> obj;
01083                                         root.QueryInterface(&obj);
01084                                         return obj.Detach();
01085                                 }
01086                                 else 
01087                                 {
01088                                         IMgaObject* o = folderFindByPath(root,  strPath2);
01089                                         if (o)
01090                                                 return o;
01091                                 }
01092                         }
01093                         return NULL;
01094                 }
01095 
01096                 CComPtr<IMgaObjects> iobjects;
01097                 COMTHROW(folder->get_ChildObjects(&iobjects));
01098                 CComPtr<IMgaObject> item;
01099                 long count = 0;
01100                 COMTHROW(iobjects->get_Count(&count));
01101                 for (int i=1; i<=count; i++)
01102                 {
01103                         COMTHROW(iobjects->get_Item(i, &item));
01104                         CComBSTR strname;
01105                         COMTHROW(item->get_Name(&strname));
01106                         if ( strName == (wstring)(WCHAR*)(BSTR)strname) 
01107                         {
01108                                 if ( strPath2.empty() )
01109                                         return item.Detach();
01110                                 else 
01111                                 {
01112                                         CComPtr<IMgaModel> model;
01113                                         CComPtr<IMgaFolder> folder;
01114                                         item.QueryInterface(&model);
01115                                         item.QueryInterface(&folder);
01116                                         if ( model) 
01117                                         {
01118                                                 IMgaObject *o = modelFindByPath(model,  strPath2);
01119                                                 if (o)
01120                                                         return o;
01121                                         }
01122                                         if ( folder) 
01123                                         {
01124                                                 IMgaObject* o = folderFindByPath(folder,  strPath2);
01125                                                 if (o)
01126                                                         return o;
01127                                         }
01128                                 }
01129                         }
01130                         item.Release();
01131                 }
01132         } 
01133         catch(hresult_exception &e) 
01134         { 
01135                 // SetErrorInfo(e.hr); 
01136                 return NULL; 
01137         } 
01138 
01139         return NULL;
01140 }
01141 
01142 
01143 IMgaObject*     CMainFrame::modelFindByPath(IMgaModel *model,  const wstring& strPath)
01144 {
01145         wstring strPath2;
01146         wstring strName;
01147         wstring::size_type iPos = strPath.find( L"/" );
01148         if ( iPos == wstring::npos ) 
01149         {
01150                 strName = strPath;
01151                 strPath2 = L"";
01152         }
01153         else 
01154         {
01155                 if ( iPos == 0 )
01156                         strPath2 = strPath.substr( iPos + 1);
01157                 iPos = strPath2.find( L"/" );
01158                 if ( iPos == wstring::npos ) 
01159                 {
01160                         strName = strPath2;
01161                         strPath2 = L"";
01162                 }
01163                 else 
01164                 {
01165                         strName = strPath2.substr( 0, iPos );
01166                         strPath2 = strPath2.substr( iPos );
01167                 }
01168         }
01169 
01170         COMTRY {
01171                 CComPtr<IMgaFCOs> fcos;
01172                 COMTHROW(model->get_ChildFCOs(&fcos));
01173                 CComPtr<IMgaFCO> item;
01174                 long count = 0;
01175                 COMTHROW(fcos->get_Count(&count));
01176                 for (int i=1; i<=count; i++)
01177                 {
01178                         COMTHROW(fcos->get_Item(i, &item));
01179                         CComBSTR strname;
01180                         COMTHROW(item->get_Name(&strname));
01181                         if ( strName == (wstring)(WCHAR*)(BSTR)strname) 
01182                         {
01183                                 if ( strPath2.empty() )
01184                                         return item.Detach();
01185                                 else 
01186                                 {
01187                                         CComPtr<IMgaModel> model;
01188                                         item.QueryInterface(&model);
01189                                         if (model )
01190                                         {
01191                                                 IMgaObject* o = modelFindByPath(model,  strPath2);
01192                                                 if (o)
01193                                                         return o;
01194                                         }
01195 
01196                                 }
01197                         }
01198                         item.Release();
01199                 }
01200         } 
01201         catch(hresult_exception &e) 
01202         { 
01203                 // SetErrorInfo(e.hr); 
01204                 return NULL; 
01205         } 
01206 
01207         return NULL;
01208 }
01209 */
01210 
01211 
01212 
01213 void CMainFrame::OnViewMultiUserRefreshSourceControl() 
01214 {
01215         BeginWaitCursor();
01216         try
01217         {
01218                 theApp.mgaProject->UpdateSourceControlInfo( 0);
01219                 m_browser.RefreshAll();
01220         }
01221         catch(...)
01222         {
01223         }  
01224         EndWaitCursor();
01225 }
01226 
01227 void CMainFrame::OnUpdateViewMultiUserRefreshSourceControl(CCmdUI* pCmdUI) 
01228 {
01229         pCmdUI->Enable( theApp.isMultiUserProj() && CGMEDoc::theInstance != 0);
01230 }
01231 
01232 void CMainFrame::OnViewMultiUserActiveUsers() 
01233 {
01234         BeginWaitCursor();
01235         try
01236         {
01237                 theApp.mgaProject->SourceControlActiveUsers();
01238         }
01239         catch(...) { ASSERT(0); }
01240         EndWaitCursor();
01241 }
01242 
01243 void CMainFrame::OnUpdateViewMultiUserActiveUsers(CCmdUI* pCmdUI) 
01244 {
01245         pCmdUI->Enable(theApp.mgaProject && (!CGMEDoc::theInstance || !theApp.isMgaProj())); // always TRUE (also when no project is open) except when mga_proj is open
01246 }
01247 
01248 void CMainFrame::OnUpdateViewMultiUserSubversion(CCmdUI* pCmdUI) 
01249 {
01250         pCmdUI->Enable(theApp.mgaProject && (!CGMEDoc::theInstance || !theApp.isMgaProj())); // always TRUE (also when no project is open) except when mga_proj is open
01251 }
01252 
01253 void CMainFrame::OnViewClearConsole() 
01254 {
01255         m_console.Clear();
01256 }
01257 
01258 void CMainFrame::OnUpdateViewClearConsole(CCmdUI* pCmdUI) 
01259 {
01260         pCmdUI->Enable();
01261 }
01262 
01263 void CMainFrame::OnDropFiles(HDROP p_hDropInfo)
01264 {
01265         CGMEEventLogger::LogGMEEvent(_T("MainFrame:OnDropFiles\r\n"));
01266         
01267         // get the number of files dropped
01268         UINT nFiles = DragQueryFile( p_hDropInfo, 0xFFFFFFFF, NULL, 0);
01269         if( nFiles < 1)
01270         {
01271                 CGMEEventLogger::LogGMEEvent(_T("Can't inquire file information!\r\n"));
01272                 m_console.Message( _T("No file dropped or can't inquire file information!"), 3);
01273         }
01274 
01275         bool one_just_opened = false; // we opened/imported one project just now -> disables opening of more .mga files
01276         for( UINT iF = 0; iF < nFiles; ++iF)
01277         {
01278                 TCHAR szFileName[_MAX_PATH];
01279                 UINT res = DragQueryFile( p_hDropInfo, iF, szFileName, _MAX_PATH);
01280                 if (res > 0)
01281                 {
01282                         bool is_dir = false; 
01283                         struct _stat fstatus;
01284                         if( 0 == _tstat( szFileName, &fstatus))
01285                                 is_dir = (fstatus.st_mode & _S_IFDIR) == _S_IFDIR;
01286                         
01287                         CString conn( szFileName);
01288                         if( is_dir || conn.Right(4).CompareNoCase(_T(".mga")) == 0 || conn.Right(4).CompareNoCase(_T(".mgx")) == 0)
01289                         {
01290                                 if( one_just_opened)
01291                                         m_console.Message( _T("Project already open. No other MGA file can be dropped!"), 3);
01292                                 else if( theApp.guiMetaProject == NULL && theApp.mgaProject == 0)
01293                                 {
01294                                         if( conn.Right(4).CompareNoCase(_T(".mga")) == 0) {
01295                                                 m_console.Message( _T("Opening ") + conn + _T("."), 1);
01296                                                 conn = _T("MGA=") + conn;
01297                                         } else {
01298                                                 int pos = conn.ReverseFind( '\\'); // we don't need the file name, only the path
01299                                                 if( is_dir)
01300                                                         conn = _T("MGX=\"") + conn + _T(")\""); // directory dropped
01301                                                 else if( pos != -1)
01302                                                         conn = _T("MGX=\"") + conn.Left( pos) + _T("\""); // the .mgx file dropped, cut off the file part
01303                                                 m_console.Message( _T("Opening multiuser project ") + conn + _T("."), 1);
01304                                         }
01305                                         theApp.OpenProject(conn);
01306                                         one_just_opened = true;
01307                                 }
01308                                 else
01309                                         m_console.Message( _T("Another MGA file can't be opened while a project is open."), 3);
01310                         }
01311                         else if( conn.Right(4).CompareNoCase(_T(".xme"))==0)
01312                         {
01313                                 theApp.ImportDroppedFile(conn);
01314                                 one_just_opened = true;
01315                         }
01316                         else if( conn.Right(4).CompareNoCase(_T(".xmp"))==0 || conn.Right(4).CompareNoCase(_T(".mta"))==0)
01317                         {
01318                                 if( theApp.guiMetaProject == NULL && theApp.mgaProject == 0) // no project opened
01319                                 {
01320                                         m_console.Message( _T("Registering ") + conn + _T(" as a paradigm."), 1);
01321 
01322                                         theApp.RegisterDroppedFile( conn.Right(4).CompareNoCase(_T(".xmp"))==0?_T("XML=") + conn:_T("MGA=") + conn);
01323                                         one_just_opened = false; // we did not open a file, just registered
01324                                 }
01325                                 else
01326                                         m_console.Message( _T("Can't register paradigm file while project is open!"), 3);
01327                         }
01328                         else if (conn.Right(4).CompareNoCase(_T(".htm")) == 0 || conn.Right(5).CompareNoCase(_T(".html")) == 0)
01329                         {
01330                                 m_console.NavigateTo(conn);
01331                         }
01332 
01333                         else
01334                                 m_console.Message( _T("Only .MGX, .MGA, .XME, .MTA, .XMP, and .html files may be dropped. Can't open file: ") + conn + _T("."), 3);
01335                 }
01336                 else
01337                         m_console.Message( _T("Can't inquire file information!"), 3);
01338         }
01339 }
01340 
01341 BOOL CMainFrame::PreTranslateMessage(MSG* pMsg)
01342 {
01343         return CMDIFrameWndEx::PreTranslateMessage(pMsg);
01344 }
01345 
01346 
01347 void CMainFrame::OnBtnBack()
01348 {
01349         if( !theApp.isHistoryEnabled() || !CGMEDoc::theInstance) return;
01350         CGMEDoc::theInstance->back();
01351 }
01352 
01353 void CMainFrame::OnUpdateBtnBack(CCmdUI* pCmdUI)
01354 {
01355         pCmdUI->Enable( theApp.isHistoryEnabled() && CGMEDoc::theInstance && CGMEDoc::theInstance->m_historian.isEnabledBack());
01356 }
01357 
01358 void CMainFrame::OnBtnHome()
01359 {
01360         if( !theApp.isHistoryEnabled() || !CGMEDoc::theInstance) return;
01361         CGMEDoc::theInstance->home();
01362 }
01363 
01364 void CMainFrame::OnUpdateBtnHome(CCmdUI* pCmdUI)
01365 {
01366         pCmdUI->Enable( theApp.isHistoryEnabled() && CGMEDoc::theInstance && CGMEDoc::theInstance->m_historian.isEnabledHome());
01367 }
01368 
01369 void CMainFrame::OnUpdateApplicationLook(CCmdUI* pCmdUI)
01370 {
01371         pCmdUI->SetRadio(theApp.m_nAppLook == pCmdUI->m_nID);
01372 }
01373 
01374 
01375 void CMainFrame::OnApplicationLook(UINT id)
01376 {
01377         CWaitCursor wait;
01378 
01379         theApp.m_nAppLook = id;
01380 
01381         switch (theApp.m_nAppLook)
01382         {
01383         case ID_VIEW_APPLOOK_WIN_2000:
01384                 CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManager));
01385                 break;
01386 
01387         case ID_VIEW_APPLOOK_OFF_XP:
01388                 CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerOfficeXP));
01389                 break;
01390 
01391         case ID_VIEW_APPLOOK_WIN_XP:
01392                 CMFCVisualManagerWindows::m_b3DTabsXPTheme = TRUE;
01393                 CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerWindows));
01394                 break;
01395 
01396         case ID_VIEW_APPLOOK_OFF_2003:
01397                 CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerOffice2003));
01398                 CDockingManager::SetDockingMode(DT_SMART);
01399                 break;
01400 
01401         case ID_VIEW_APPLOOK_VS_2005:
01402                 CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerVS2005));
01403                 CDockingManager::SetDockingMode(DT_SMART);
01404                 break;
01405 
01406         default:
01407                 switch (theApp.m_nAppLook)
01408                 {
01409                 case ID_VIEW_APPLOOK_OFF_2007_BLUE:
01410                         CMFCVisualManagerOffice2007::SetStyle(CMFCVisualManagerOffice2007::Office2007_LunaBlue);
01411                         break;
01412 
01413                 case ID_VIEW_APPLOOK_OFF_2007_BLACK:
01414                         CMFCVisualManagerOffice2007::SetStyle(CMFCVisualManagerOffice2007::Office2007_ObsidianBlack);
01415                         break;
01416 
01417                 case ID_VIEW_APPLOOK_OFF_2007_SILVER:
01418                         CMFCVisualManagerOffice2007::SetStyle(CMFCVisualManagerOffice2007::Office2007_Silver);
01419                         break;
01420 
01421                 case ID_VIEW_APPLOOK_OFF_2007_AQUA:
01422                         CMFCVisualManagerOffice2007::SetStyle(CMFCVisualManagerOffice2007::Office2007_Aqua);
01423                         break;
01424                 }
01425 
01426                 CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerOffice2007));
01427                 CDockingManager::SetDockingMode(DT_SMART);
01428         }
01429 
01430         RedrawWindow(NULL, NULL, RDW_ALLCHILDREN | RDW_INVALIDATE | RDW_UPDATENOW | RDW_FRAME | RDW_ERASE);
01431 
01432         theApp.WriteInt(_T("ApplicationLook"), theApp.m_nAppLook);
01433 
01434 }
01435 
01436 
01437 void CMainFrame::OnWindowManager()
01438 {
01439         ShowWindowsDialog();
01440 }
01441 
01442 void CMainFrame::OnViewCustomize()
01443 {
01444         CMFCToolBarsCustomizeDialog* pDlgCust = new CMFCToolBarsCustomizeDialog(this, TRUE /* scan menus */);
01445         pDlgCust->EnableUserDefinedToolbars();
01446         pDlgCust->Create();
01447 }
01448 
01449 void CMainFrame::OnViewFullScreen()
01450 {
01451         ShowFullScreen();
01452 }
01453 
01454 
01455 /*
01456 
01457 void CMainFrame::OnHelpKeyboardmap()
01458 {
01459         CMFCKeyMapDialog dlg(this, TRUE ); // Enable Print
01460         dlg.DoModal();
01461 }
01462 
01463 */
01464 
01465 LRESULT CMainFrame::OnToolbarCreateNew(WPARAM wp,LPARAM lp)
01466 {
01467         LRESULT lres = CMDIFrameWndEx::OnToolbarCreateNew(wp,lp);
01468         if (lres == 0)
01469         {
01470                 return 0;
01471         }
01472 
01473         CMFCToolBar* pUserToolbar = (CMFCToolBar*) lres;
01474         ASSERT_VALID(pUserToolbar);
01475 
01476         pUserToolbar->EnableCustomizeButton(TRUE, ID_VIEW_CUSTOMIZE, _T("Customize..."));
01477         return lres;
01478 }
01479 
01480 void CMainFrame::OnUpdateControlBarMenus(CCmdUI* pCmdUI)
01481 {
01482         switch (pCmdUI->m_nID) {
01483                 case IDW_TOOLBAR_MAIN:          pCmdUI->SetCheck(m_wndToolBarMain.IsVisible());         break;
01484                 case IDW_TOOLBAR_WINS:          pCmdUI->SetCheck(m_wndToolBarWins.IsVisible());         break;
01485                 case IDW_TOOLBAR_COMPONENT:     pCmdUI->SetCheck(m_wndComponentBar.IsVisible());        break;
01486                 case IDW_TOOLBAR_MODE:          pCmdUI->SetCheck(m_wndModeBar.IsVisible());                     break;
01487                 case IDW_TOOLBAR_NAVIG:         pCmdUI->SetCheck(m_wndNaviBar.IsVisible());                     break;
01488                 case IDW_TOOLBAR_MODELING:      pCmdUI->SetCheck(m_wndToolBarModeling.IsVisible());     break;
01489                 default: ASSERT(false);
01490         }
01491 }
01492 
01493 BOOL CMainFrame::OnBarCheck(UINT nID)
01494 {
01495         switch (nID) {
01496                 case IDW_TOOLBAR_MAIN:          ShowPane(&m_wndToolBarMain,             !m_wndToolBarMain.IsVisible(),          FALSE, FALSE); break;
01497                 case IDW_TOOLBAR_WINS:          ShowPane(&m_wndToolBarWins,             !m_wndToolBarWins.IsVisible(),          FALSE, FALSE); break;
01498                 case IDW_TOOLBAR_COMPONENT:     ShowPane(&m_wndComponentBar,    !m_wndComponentBar.IsVisible(),         FALSE, FALSE); break;
01499                 case IDW_TOOLBAR_MODE:          ShowPane(&m_wndModeBar,                 !m_wndModeBar.IsVisible(),                      FALSE, FALSE); break;
01500                 case IDW_TOOLBAR_NAVIG:         ShowPane(&m_wndNaviBar,                 !m_wndNaviBar.IsVisible(),                      FALSE, FALSE); break;
01501                 case IDW_TOOLBAR_MODELING:      ShowPane(&m_wndToolBarModeling, !m_wndToolBarModeling.IsVisible(),      FALSE, FALSE); break;
01502                 default: return FALSE;
01503         }
01504         return TRUE;
01505 }
01506 
01507 void CMainFrame::OnWindowNewhorizontaltabgroup()
01508 {
01509         MDITabNewGroup(FALSE);
01510 }
01511 
01512 void CMainFrame::OnWindowNewverticaltabgroup()
01513 {
01514         MDITabNewGroup();
01515 }
01516 
01517 void CMainFrame::OnWindowMovetoprevioustabgroup()
01518 {
01519         MDITabMoveToNextGroup(FALSE);
01520 }
01521 
01522 void CMainFrame::OnWindowMovetonexttabgroup()
01523 {
01524         MDITabMoveToNextGroup();
01525 }
01526 
01527 void CMainFrame::OnUpdateWindowNewhorizontaltabgroup(CCmdUI* pCmdUI)
01528 {
01529         DWORD dwAllowedItems = GetMDITabsContextMenuAllowedItems();
01530         if ((dwAllowedItems & AFX_MDI_CREATE_HORZ_GROUP) == 0)
01531         {
01532                 pCmdUI->Enable(FALSE);
01533         }
01534         else
01535         {
01536                 pCmdUI->Enable(TRUE);
01537         }
01538 }
01539 
01540 void CMainFrame::OnUpdateWindowNewverticaltabgroup(CCmdUI* pCmdUI)
01541 {
01542         DWORD dwAllowedItems = GetMDITabsContextMenuAllowedItems();
01543         if ((dwAllowedItems & AFX_MDI_CREATE_VERT_GROUP) == 0)
01544         {
01545                 pCmdUI->Enable(FALSE);
01546         }
01547         else
01548         {
01549                 pCmdUI->Enable(TRUE);
01550         }
01551 }
01552 
01553 void CMainFrame::OnUpdateWindowMovetoprevioustabgroup(CCmdUI* pCmdUI)
01554 {
01555         DWORD dwAllowedItems = GetMDITabsContextMenuAllowedItems();
01556         if ((dwAllowedItems & AFX_MDI_CAN_MOVE_PREV) == 0)
01557         {
01558                 pCmdUI->Enable(FALSE);
01559         }
01560         else
01561         {
01562                 pCmdUI->Enable(TRUE);
01563         }
01564 }
01565 
01566 void CMainFrame::OnUpdateWindowMovetonexttabgroup(CCmdUI* pCmdUI)
01567 {
01568         DWORD dwAllowedItems = GetMDITabsContextMenuAllowedItems();
01569         if ((dwAllowedItems & AFX_MDI_CAN_MOVE_NEXT) == 0)
01570         {
01571                 pCmdUI->Enable(FALSE);
01572         }
01573         else
01574         {
01575                 pCmdUI->Enable(TRUE);
01576         }
01577 }
01578 
01579 LRESULT CMainFrame::OnGetTabTooltip(WPARAM /*wParam*/, LPARAM lParam)
01580 {
01581         CMFCTabToolTipInfo* pInfo = (CMFCTabToolTipInfo*)lParam;
01582         ASSERT(pInfo != NULL);
01583 
01584         if (pInfo)
01585         {
01586                 CMFCBaseTabCtrl* tabControl = pInfo->m_pTabWnd;
01587                 ASSERT_VALID(tabControl);
01588                 if (tabControl->IsMDITab())
01589                 {
01590                         CWnd* tabPaneWnd = tabControl->GetTabWndNoWrapper(pInfo->m_nTabIndex);
01591                         if (tabPaneWnd->IsKindOf(RUNTIME_CLASS(CChildFrame))) {
01592                                 CChildFrame* childFrame = STATIC_DOWNCAST(CChildFrame, tabPaneWnd);
01593                                 pInfo->m_strText = childFrame->GetTitle() + _T(" - ") + childFrame->GetAppTitle();
01594                         }
01595                 }
01596         }
01597 
01598         return 0;
01599 }
01600 
01601 void CMainFrame::ShowNavigationAndModeToolbars(bool isVisible)
01602 {
01603         ShowPane(&m_wndModeBar, isVisible, FALSE, FALSE);
01604         ShowPane(&m_wndNaviBar, isVisible, FALSE, FALSE);
01605 }
01606 
01607 void CMainFrame::OnUpdateWindowNew(CCmdUI* pCmdUI)
01608 {
01609         pCmdUI->Enable(FALSE);
01610 }
01611 
01612 void CMainFrame::CheckForOffscreenPanes()
01613 {
01614         // it seems Windows does this for us when resolution is changed, so no need to handle WM_DISPLAYCHANGE
01615         // but it is possible to float a pane, then close GME, then change the screen resolution
01616 
01617         // TODO: these can float offscreen too...
01618         //m_wndComponentBar; m_wndStatusBar; m_wndToolBarMain; m_wndToolBarModeling; m_wndToolBarWins; m_wndMenuBar; m_wndModeBar; m_wndNaviBar;
01619         CDockablePane* panes[] = { &m_panningWindow, &m_console, &m_partBrowser, &m_browser, &m_objectInspector, &m_search, nullptr };
01620         CDockablePane** pane = panes;
01621         while (*pane)
01622         {
01623                 HMONITOR mon = MonitorFromWindow((*pane)->GetSafeHwnd(), MONITOR_DEFAULTTONULL);
01624                 bool flt = (*pane)->IsFloating();
01625                 if (mon == nullptr && flt)
01626                 {
01627                         DockPane(*pane, AFX_IDW_DOCKBAR_BOTTOM);
01628                 }
01629                 pane++;
01630         }
01631         return;
01632 }