home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / cmd / winfe / frameglu.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  17.7 KB  |  591 lines

  1. /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  2.  *
  3.  * The contents of this file are subject to the Netscape Public License
  4.  * Version 1.0 (the "NPL"); you may not use this file except in
  5.  * compliance with the NPL.  You may obtain a copy of the NPL at
  6.  * http://www.mozilla.org/NPL/
  7.  *
  8.  * Software distributed under the NPL is distributed on an "AS IS" basis,
  9.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
  10.  * for the specific language governing rights and limitations under the
  11.  * NPL.
  12.  *
  13.  * The Initial Developer of this code under the NPL is Netscape
  14.  * Communications Corporation.  Portions created by Netscape are
  15.  * Copyright (C) 1998 Netscape Communications Corporation.  All Rights
  16.  * Reserved.
  17.  */
  18.  
  19. #include "stdafx.h"
  20. #include "secnav.h"
  21. #include "frameglu.h"
  22. #include "mainfrm.h"
  23. #include "ipframe.h"
  24. #include "prefapi.h"
  25.  
  26. //    Our active frame stack.
  27. CPtrList CFrameGlue::m_cplActiveFrameStack;
  28.  
  29.  
  30. //    A way to correctly get the frame glue out of a frame at run time though
  31. //        the class derivations and casting are not right....
  32. CFrameGlue *CFrameGlue::GetFrameGlue(CFrameWnd *pFrame)    {
  33.     //    Use IsKindOf to determine the frame's class type.
  34.     //    From there, we can correctly cast the frame window pointer, and
  35.     //        further cast to the abstract base class of CFrameGlue.
  36.     CFrameGlue *pRetval = NULL;
  37.     if(pFrame->IsKindOf(RUNTIME_CLASS(CGenericFrame)))    {
  38.         pRetval = (CFrameGlue *)((CGenericFrame *)pFrame);        
  39.     }
  40.     else if(pFrame->IsKindOf(RUNTIME_CLASS(CInPlaceFrame)))    {
  41.         pRetval = (CFrameGlue *)((CInPlaceFrame *)pFrame);
  42.     }
  43.  
  44. #ifdef DEBUG
  45.     if(pRetval == NULL)    {
  46.         //    If you got here, either you need to add appropriate casting statements
  47.         //        in the above if to resolve the CFrameGlue, or you have found a bug.
  48.         TRACE("Invalid frame window has no frame glue!\n");
  49. //        ASSERT(0);
  50.     }
  51. #endif // DEBUG
  52.  
  53.     return(pRetval);
  54. }
  55.  
  56.  
  57. CFrameGlue::CFrameGlue()    {
  58.     m_pActiveContext = NULL;
  59.     m_pMainContext = NULL;
  60.     m_bCanRestoreState = FALSE;
  61.     m_iCSID = theApp.m_iCSID;
  62.     m_pChrome = NULL;
  63.  
  64.     // location bar
  65.     // note I just changed this from 1.0 version to be more appropriate chouck 24-jan-95
  66.     XP_Bool bBar;
  67.     PREF_GetBoolPref("browser.chrome.show_url_bar",&bBar);
  68.     m_bLocationBar = bBar;
  69.  
  70.     // show the starter buttons?
  71.     PREF_GetBoolPref("browser.chrome.show_directory_buttons",&bBar);
  72.     m_bStarter = bBar;
  73.  
  74.     PREF_GetBoolPref("browser.chrome.show_toolbar",&bBar);
  75.     m_bShowToolbar = bBar;
  76.  
  77.     //    No find replace dialog yet.
  78.     m_pFindReplace = NULL;
  79.  
  80.     m_pClipChildMap = NULL;
  81.     m_isBackgroundPalette = FALSE;
  82. }
  83.  
  84. CFrameGlue::~CFrameGlue()    {
  85.     //    Take all entries of this frame in the active frame stack out.
  86.     POSITION pos;
  87.  
  88.     while( pos = m_cplActiveFrameStack.Find( (LPVOID) this ) ){
  89.         m_cplActiveFrameStack.RemoveAt( pos );
  90.     }
  91.  
  92.  
  93.     //    When the frame goes down, let the window context know.
  94.     if(GetMainWinContext())    {
  95.         GetMainWinContext()->ClearFrame();
  96.     }
  97.  
  98.     if( m_pClipChildMap != NULL ) {
  99.         m_pClipChildMap->RemoveAll();
  100.  
  101.         delete m_pClipChildMap;
  102.         m_pClipChildMap = NULL;
  103.     }
  104. }
  105.  
  106.  
  107. //    Generic way to get a frame out of the context.
  108. CFrameGlue *GetFrame(MWContext *pContext)    
  109. {
  110.     CFrameGlue *pRetval = NULL;
  111.     if(pContext != NULL)    {
  112.         if(ABSTRACTCX(pContext) && ABSTRACTCX(pContext)->IsFrameContext())    {
  113.             pRetval = ABSTRACTCX(pContext)->GetFrame();
  114.         }
  115.     }
  116.  
  117.     return(pRetval);
  118. }
  119.  
  120. CAbstractCX *CFrameGlue::GetMainContext() const
  121. {
  122.     return(m_pMainContext);
  123. }
  124.  
  125. CAbstractCX *CFrameGlue::GetActiveContext() const 
  126. {
  127.     return(m_pActiveContext);
  128. }
  129.  
  130. CWinCX *CFrameGlue::GetMainWinContext() const
  131. {
  132.     if (m_pMainContext && m_pMainContext->IsFrameContext()) {        
  133.         return((CWinCX *) m_pMainContext);
  134.     }
  135.     return NULL;
  136. }
  137.  
  138. CWinCX *CFrameGlue::GetActiveWinContext() const
  139. {
  140.     if (m_pActiveContext && m_pActiveContext->IsFrameContext()) {        
  141.         return((CWinCX *) m_pActiveContext);
  142.     }
  143.     return NULL;
  144. }
  145.  
  146. void CFrameGlue::SetMainContext(CAbstractCX *pContext)    {
  147.     m_pMainContext = pContext;
  148. }
  149.  
  150. CPtrList CFrameGlue::m_cplActiveContextCBList;
  151.  
  152. void CFrameGlue::SetActiveContext(CAbstractCX *pContext)
  153. {
  154.     m_pActiveContext = pContext;
  155.  
  156.     POSITION rIndex = m_cplActiveContextCBList.GetHeadPosition();
  157.     while(rIndex != NULL)   {
  158.         ActiveContextCB cb = (ActiveContextCB)m_cplActiveContextCBList.GetNext(rIndex);
  159.         (cb)(this, pContext);
  160.     }
  161. }
  162.  
  163. void CFrameGlue::AddActiveContextCB(ActiveContextCB cb)
  164. {
  165.     m_cplActiveContextCBList.AddTail((LPVOID)cb);
  166. }
  167.  
  168. void CFrameGlue::RemoveActiveContextCB(ActiveContextCB cb)
  169. {
  170.     POSITION rIndex = m_cplActiveContextCBList.Find((LPVOID)cb);
  171.     if(rIndex)  {
  172.         m_cplActiveContextCBList.RemoveAt(rIndex);
  173.     }
  174. }
  175.  
  176. // Override to test if frame is an editor
  177. BOOL CFrameGlue::IsEditFrame() 
  178. {
  179.     return(FALSE);
  180. }
  181.  
  182. CPtrList CFrameGlue::m_cplActiveNotifyCBList;
  183.  
  184. //    Add to the top of the stack of active frames.
  185. void CFrameGlue::SetAsActiveFrame()
  186. {
  187.     POSITION rIndex = m_cplActiveNotifyCBList.GetHeadPosition();
  188.     while(rIndex != NULL)    {
  189.         ActiveNotifyCB cb = (ActiveNotifyCB) m_cplActiveNotifyCBList.GetNext(rIndex);
  190.         (cb)(this);
  191.     }
  192.  
  193.     POSITION pos = m_cplActiveFrameStack.Find( (LPVOID) this );
  194.     if (pos) {
  195.         m_cplActiveFrameStack.RemoveAt( pos );
  196.     }
  197.  
  198.     TRY    {
  199.         m_cplActiveFrameStack.AddHead((void *)this);
  200.  
  201.     }
  202.     CATCH(CException, e)    {
  203.         //    didn't work, Silently fail...
  204.         ASSERT(0);
  205.     }
  206.     END_CATCH
  207. }
  208.  
  209. void CFrameGlue::AddActiveNotifyCB( ActiveNotifyCB cb )
  210. {
  211.     m_cplActiveNotifyCBList.AddTail( (LPVOID) cb );
  212. }
  213.  
  214. void CFrameGlue::RemoveActiveNotifyCB( ActiveNotifyCB cb )
  215. {
  216.     POSITION rIndex = m_cplActiveNotifyCBList.Find( (LPVOID) cb );
  217.     if (rIndex) {
  218.         m_cplActiveNotifyCBList.RemoveAt( rIndex );
  219.     }
  220. }
  221.  
  222. //    Find a browser window in the active stack, only use cxType types.
  223. //  Default is to NOT find editor windows when cxType = MWContextBrowser
  224. CFrameGlue *CFrameGlue::GetLastActiveFrame(MWContextType cxType, int nFindEditor)
  225. {
  226.     CFrameGlue *pRetval = NULL;
  227.  
  228.     //    Loop through all active frames.
  229.     POSITION rIndex = m_cplActiveFrameStack.GetHeadPosition();
  230.     while(rIndex != NULL)    {
  231.         pRetval = (CFrameGlue *)m_cplActiveFrameStack.GetNext(rIndex);
  232.         
  233.         //    See if we can get the type from the context, and verify the type.
  234.         if(pRetval->GetMainContext() != NULL)    {
  235.             MWContextType cxRetType = pRetval->GetMainContext()->GetContext()->type;
  236.             if(cxType == MWContextAny || cxRetType == cxType)    {
  237.                 // If looking for only Browser, skip an editor frame
  238.                 if (cxType == MWContextBrowser){
  239.                     BOOL bIsEditor = EDT_IS_EDITOR(pRetval->GetMainContext()->GetContext());
  240.                     if((nFindEditor == FEU_FINDBROWSERONLY && bIsEditor) ||
  241.                        (nFindEditor == FEU_FINDEDITORONLY && !bIsEditor)) {
  242.                 
  243.                     //    Failed the check. clear retval.
  244.                         pRetval = NULL;
  245.                         continue;
  246.                     }
  247.                 }
  248.  
  249.                 // Don't allow Netcaster either
  250.                 if (pRetval->GetMainContext()->GetContext() == theApp.m_pNetcasterWindow
  251.                 || (pRetval->GetMainContext()->GetContext()->name && (XP_STRCASECMP(pRetval->GetMainContext()->GetContext()->name,"Netscape_Netcaster_Drawer") == 0))) {
  252.                     pRetval = NULL;
  253.                     continue;
  254.                 }
  255.  
  256.                 //    Found one.
  257.                 break;
  258.             }
  259.         }
  260.  
  261.         //    Failed the check. clear retval.
  262.         pRetval = NULL;
  263.     }
  264.  
  265.     return(pRetval);
  266. }
  267.  
  268. CFrameGlue *CFrameGlue::GetLastActiveFrameByCustToolbarType(CString custToolbar, CFrameWnd *pCurrentFrame, BOOL bUseSaveInfo)
  269. {
  270.  
  271.     CFrameGlue *pRetval = NULL;
  272.  
  273.     //    Loop through all active frames.
  274.     POSITION rIndex = m_cplActiveFrameStack.GetHeadPosition();
  275.     while(rIndex != NULL)    {
  276.         
  277.         pRetval = (CFrameGlue *)m_cplActiveFrameStack.GetNext(rIndex);
  278.         
  279.         // if it's the current frame, then keep looking because we want the one before it.
  280.         if(pRetval->GetFrameWnd() == pCurrentFrame)    {
  281.             pRetval = NULL;
  282.             continue;
  283.         }
  284.         //    See if we share the same custtoolbar string.
  285.         if((pRetval->m_pChrome) && (pRetval->m_pChrome->GetCustToolbarString() == custToolbar)){
  286.             if(bUseSaveInfo){
  287.             // if customizable toolbar saves its prefs, then break
  288.             // this is used to ignore windows like View Page Source and View Page Info
  289.              if(pRetval->m_pChrome->GetCustomizableToolbar()->GetSaveToolbarInfo())
  290.                 break;
  291.             }
  292.             else
  293.                 break;
  294.         }
  295.  
  296.         //    Failed the check. clear retval.
  297.         pRetval = NULL;
  298.     }
  299.  
  300.     return(pRetval);
  301. }
  302.  
  303. CFrameGlue *CFrameGlue::GetBottomFrame(MWContextType cxType, int nFindEditor)
  304. {
  305.  
  306.     CFrameGlue *pRetval = NULL;
  307.  
  308.     //    Loop through all active frames until we reach the bottom.
  309.     POSITION rIndex = m_cplActiveFrameStack.GetTailPosition();
  310.     while(rIndex != NULL)    {
  311.         pRetval = (CFrameGlue *)m_cplActiveFrameStack.GetPrev(rIndex);
  312.  
  313.  
  314.         //    See if we can get the type from the context, and verify the type.
  315.         if(pRetval->GetMainContext() != NULL)    {
  316.             MWContextType cxRetType = pRetval->GetMainContext()->GetContext()->type;
  317.             if(cxType == MWContextAny || cxRetType == cxType)    {
  318.                 // If looking for only Browser, skip an editor frame
  319.                  if (cxType == MWContextBrowser){
  320.                     BOOL bIsEditor = EDT_IS_EDITOR(pRetval->GetMainContext()->GetContext());
  321.                     if((nFindEditor == FEU_FINDBROWSERONLY && bIsEditor) ||
  322.                        (nFindEditor == FEU_FINDEDITORONLY && !bIsEditor)) {
  323.                     //    Failed the check. clear retval.
  324.                         continue;
  325.                     }
  326.                 }
  327.                 // Found one
  328.                 break;
  329.             }
  330.         }
  331.     }
  332.  
  333.     return(pRetval);
  334.  
  335. }
  336.  
  337. // Find the number of active frames of type cxType
  338. int CFrameGlue::GetNumActiveFrames(MWContextType cxType, int nFindEditor)
  339. {
  340.     int nCount = 0;
  341.     CFrameGlue *pRetval = NULL;
  342.     //    Loop through all active frames.
  343.     POSITION rIndex = m_cplActiveFrameStack.GetHeadPosition();
  344.     while(rIndex != NULL)    {
  345.         pRetval = (CFrameGlue *)m_cplActiveFrameStack.GetNext(rIndex);
  346.         
  347.         //    See if we can get the type from the context, and verify the type.
  348.         if(pRetval->GetMainContext() != NULL)    {
  349.             MWContextType cxRetType = pRetval->GetMainContext()->GetContext()->type;
  350.             if(cxType == MWContextAny || cxRetType == cxType)    {
  351.                 // If looking for only Browser, skip an editor frame
  352.                 if (cxType == MWContextBrowser){
  353.                     BOOL bIsEditor = EDT_IS_EDITOR(pRetval->GetMainContext()->GetContext());
  354.                     if((nFindEditor == FEU_FINDBROWSERONLY && bIsEditor) ||
  355.                         (nFindEditor == FEU_FINDEDITORONLY && !bIsEditor)) {
  356.  
  357.                           continue;
  358.                     }
  359.                 }
  360.                 //    Found one so increase count.
  361.  
  362.                 nCount++;
  363.             }
  364.         }
  365.     }
  366.  
  367.     return(nCount);
  368.  
  369. }
  370.  
  371. //    Find a browser window by context ID....
  372. CFrameGlue *CFrameGlue::FindFrameByID(DWORD dwID, MWContextType cxType)
  373. {
  374.     CFrameGlue *pRetval = NULL;
  375.  
  376.     //    Must have a context first.
  377.     CAbstractCX *pCX = CAbstractCX::FindContextByID(dwID);
  378.     if(pCX != NULL)    {
  379.         //    Must be a window context.
  380.         if(pCX->IsFrameContext() == TRUE)    {
  381.             //    Make sure the context is of the correct type.
  382.             if(cxType == MWContextAny || cxType == pCX->GetContext()->type)    {
  383.                 pRetval = VOID2CX(pCX, CAbstractCX)->GetFrame();
  384.             }
  385.         }
  386.     }
  387.  
  388.     return(pRetval);
  389. }
  390.  
  391. //    Common command handler for all frames.
  392. //    Call in your OnCommand derivation.
  393. BOOL CFrameGlue::CommonCommand(UINT wParam, LONG lParam)    {
  394.     UINT nID = LOWORD(wParam);
  395.  
  396.     if (IS_PLACESMENU_ID(nID)  || IS_HELPMENU_ID(nID)) {
  397.         char * url = NULL;
  398.         if (IS_PLACESMENU_ID(nID))
  399.             PREF_CopyIndexConfigString("menu.places.item",CASTINT(nID-FIRST_PLACES_MENU_ID),"url",&url);
  400.         else 
  401.             PREF_CopyIndexConfigString("menu.help.item",CASTINT(nID-FIRST_HELP_MENU_ID),"url",&url);
  402.         if (!url) return FALSE;
  403.  
  404.         if(!GetMainContext())
  405.             return(FALSE);
  406.         // if we are a browser window and NOT an editor just load it locally
  407.         if(GetMainContext()->GetContext()->type == MWContextBrowser &&
  408.            !EDT_IS_EDITOR(GetMainContext()->GetContext()) ){
  409.             GetMainContext()->NormalGetUrl(url);
  410.             return(TRUE);
  411.         }
  412.  
  413.         // look for a browser window we can load into
  414.         CFrameGlue *pFrameGlue = CFrameGlue::GetLastActiveFrame(MWContextBrowser);
  415.         if(pFrameGlue != NULL && pFrameGlue->GetMainContext() != NULL)    {
  416.             CAbstractCX * pCX = pFrameGlue->GetMainContext();
  417.             if (pCX != NULL) {
  418.                 CFrameWnd * pWnd = pFrameGlue->GetFrameWnd();
  419.                 if (pWnd->IsIconic())
  420.                     pWnd->ShowWindow(SW_RESTORE);
  421.                 pWnd->BringWindowToTop();
  422.                 pCX->NormalGetUrl(url);
  423.             }
  424. //            pFrameGlue->GetMainContext()->NormalGetUrl(szLoadString(nID + LOAD_URL_COUNT));
  425.             return(TRUE);
  426.         }
  427.  
  428.         // if we got here we must not have found a viable window --- create a new one
  429.         MWContext * pContext = CFE_CreateNewDocWindow(NULL, NULL);
  430.         ABSTRACTCX(pContext)->NormalGetUrl(url);
  431.         XP_FREE(url);
  432.         return(TRUE);    
  433.     } else if ( nID == ID_SECURITY_ADVISOR ) {
  434.         CAbstractCX *pCX = GetMainContext();
  435.         if (pCX != NULL) 
  436.         {
  437.             MWContext * pContext = pCX->GetContext();
  438.             if (pContext != NULL)
  439.             {
  440.                 URL_Struct * pURL = pCX->CreateUrlFromHist(TRUE);
  441.  
  442.                 SECNAV_SecurityAdvisor(pContext, pURL);
  443.             }
  444.         }
  445.     }
  446.  
  447.     return(FALSE);
  448. }
  449.  
  450. #define CLIP_BIT        0x80000000L
  451. #define GET_CLIP_BIT(x) ( (DWORD)(x) & CLIP_BIT )
  452. #define CLIP_COUNT(x)   ( (DWORD)(x) & 0x0000FFFFL )
  453.  
  454. void CFrameGlue::ClipChildren(CWnd *pWnd, BOOL bSet)
  455. {
  456.  
  457. //    ASSERT( GetFrameWnd()->IsChild(pWnd) );
  458. #ifdef _DEBUG
  459.     if (GetFrameWnd() && !GetFrameWnd()->IsChild(pWnd))
  460.         TRACE("pWnd is not a child of this frame\n");
  461. #endif
  462.     // If the child window hash table does not exist, then create one
  463.     if( m_pClipChildMap == NULL ) {
  464.         m_pClipChildMap = new CMapPtrToPtr();
  465.     }
  466.     //
  467.     // For every window in the hierarchy between pWnd and the top level 
  468.     // frame, set or clear its WS_CLIPCHILDREN style bit.
  469.     //
  470.     while( (pWnd = pWnd->GetParent()) != NULL ) {
  471.         DWORD dwStyle;
  472.         void *item = 0;
  473.         void *key = (void*)pWnd->m_hWnd;
  474.  
  475.         dwStyle = ::GetWindowLong(pWnd->m_hWnd, GWL_STYLE);
  476.  
  477.         // Add the window to the map if necessary...
  478.         if( m_pClipChildMap->Lookup(key, item) == FALSE && bSet ) {
  479.  
  480.             item = (void *)((dwStyle & WS_CLIPCHILDREN) ? CLIP_BIT : 0L);
  481.             m_pClipChildMap->SetAt(key, item);
  482.         }
  483.  
  484.         // Setting the WS_CLIPCHILDREN bit...        
  485.         if( bSet ) {
  486.             // Set the style the first time...
  487.             if( CLIP_COUNT(item) == 0 ) {
  488.                 ::SetWindowLong(pWnd->m_hWnd, GWL_STYLE,(dwStyle|WS_CLIPCHILDREN));
  489.             }
  490.             // Increment the count and save the new state...
  491.             item = (void *) (((DWORD)item) + 1);
  492.             m_pClipChildMap->SetAt(key, item);
  493.         } 
  494.  
  495.         // Clearing the WS_CLIPCHILDREN bit...
  496.         else if (CLIP_COUNT(item)) {
  497.             // Decrement the count...
  498.             item = (void *) (((DWORD)item) - 1);
  499.  
  500.              // Restore the window to its original state and remove it
  501.              // from the map.
  502.             if( CLIP_COUNT(item) == 0 ) {
  503.                 if( GET_CLIP_BIT(item) == 0 ) {
  504.                     ::SetWindowLong(pWnd->m_hWnd, GWL_STYLE,
  505.                                     (dwStyle & ~WS_CLIPCHILDREN) );
  506.                 }
  507.                 m_pClipChildMap->RemoveKey(key);
  508.             } 
  509.             // Save the new state...
  510.             else {
  511.                 m_pClipChildMap->SetAt(key, item);
  512.             }
  513.         }
  514.     }
  515. }
  516.  
  517.  
  518. BOOL CFrameGlue::RealizePalette(CWnd *pWnd, HWND hFocusWnd,BOOL background)
  519. {
  520.     CWinCX *pWinCX = GetMainWinContext();
  521.     HDC hdc = pWinCX->GetContextDC();
  522.     if (hdc) {
  523.         ::SelectPalette(hdc, pWinCX->GetPalette(), background);    
  524.         int colorRealized = ::RealizePalette(hdc);
  525.         int lCount = XP_ListCount(pWinCX->GetContext()->grid_children);
  526.         if (lCount) {
  527.             //    Go through each child.
  528.             MWContext *pChild;
  529.             XP_List *pTraverse = pWinCX->GetContext()->grid_children;
  530.             while (pChild = (MWContext *)XP_ListNextObject(pTraverse)) {
  531.                 ASSERT(ABSTRACTCX(pChild)->IsWindowContext());
  532.                 ::InvalidateRect(PANECX(pChild)->GetPane(), NULL, TRUE);
  533.                 ::UpdateWindow(PANECX(pChild)->GetPane());
  534.             }
  535.         }
  536.         SetIsBackgroundPalette(background);
  537.         ::InvalidateRect(pWinCX->GetPane(), NULL, TRUE);
  538.         ::UpdateWindow(pWinCX->GetPane());
  539.     #ifdef MOZ_TASKBAR
  540.         if(theApp.GetTaskBarMgr().IsInitialized() && theApp.GetTaskBarMgr().IsFloating())
  541.             theApp.GetTaskBarMgr().ChangeTaskBarsPalette(hFocusWnd);
  542.     #endif /* MOZ_TASKBAR */
  543.         pWnd->SendMessageToDescendants(WM_PALETTECHANGED, (WPARAM)hFocusWnd);
  544.         return (colorRealized > 0) ? TRUE  : FALSE;
  545.     }
  546.     else return FALSE;
  547. }
  548.  
  549. void CFrameGlue::ClearContext(CAbstractCX *pGone) {
  550.     //    Clear out the appropriate context
  551.     //        fields, if set.
  552.     //    Can't have an active without a main.
  553.     if(GetMainContext() == pGone)    {
  554.         SetActiveContext(NULL);
  555.         SetMainContext(NULL);
  556.     }
  557.     else if(GetActiveContext() == pGone)    {
  558.         SetActiveContext(NULL);
  559.     }
  560.     else if(pGone && pGone->IsGridParent()) {
  561.         //  Need to see if pGone is a parent of the active context.
  562.         //  If so, we need to clear our active context as the child
  563.         //      context won't be able to look us up to call this
  564.         //      function due to the recursive implemenation of
  565.         //      CWinCX::GetFrame() which it uses to make this call
  566.         MWContext *pChild;
  567.         XP_List *pTraverse = pGone->GetContext()->grid_children;
  568.         while((pChild = (MWContext*)XP_ListNextObject(pTraverse)))    {
  569.             ClearContext(ABSTRACTCX(pChild));
  570.         }
  571.     }
  572. }
  573.  
  574.  
  575.  
  576. //    NULL frame implementation, for CFrameGlue when there is no frame.
  577. CFrameWnd *CNullFrame::GetFrameWnd()    {
  578.     return(NULL);
  579. }
  580.  
  581. void CNullFrame::UpdateHistoryDialog()    {
  582. }
  583.  
  584. CAbstractCX *CNullFrame::GetMainContext() const    {
  585.     return(NULL);
  586. }
  587.  
  588. CAbstractCX *CNullFrame::GetActiveContext() const    {
  589.     return(NULL);
  590. }
  591.