home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / cmd / winfe / frameglu.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  6.9 KB  |  218 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. #ifndef __FrameGlue_H
  20. //    Avoid include redundancy
  21. //
  22. #define __FrameGlue_H
  23.  
  24. //    Purpose:    Provide a class from which all frame windows are derived from
  25. //                    so that appropriate aggregation can occur between frames.
  26. //    Comments:    Created mainly because In place frames have a different derivation
  27. //                    tree than normal frame windows.  The only way to pass around a
  28. //                    common pointer is to introduce a third class which holds a common
  29. //                    API to the frame windows.
  30. //    Revision History:
  31. //        07-31-95    created GAB
  32. //
  33.  
  34. //    Required Includes
  35. //
  36. #include "apichrom.h"
  37. //    Constants
  38. //
  39.  
  40.  
  41. //    Structures
  42. //
  43. class CFrameGlue    {
  44.  
  45. //    Frames have concepts of multiple contexts.
  46. //    Provide a way to get the active (or last active) context.
  47. //    Provide a way to get the Main context (frames should always have one context).
  48. private:
  49.     CAbstractCX *m_pMainContext;
  50.     CAbstractCX *m_pActiveContext;
  51.     BOOL m_isBackgroundPalette;
  52.  
  53.  
  54. //    Need a constructor for initializations....
  55. protected:
  56.     CFrameGlue();
  57. public:
  58.     virtual ~CFrameGlue();
  59.  
  60. //    How to get the frame glue from a frame window.
  61. public:
  62.     static CFrameGlue *GetFrameGlue(CFrameWnd *pFrame);
  63.  
  64. protected:
  65.     friend class CGenericView;    //    Views can manipulate the frames active context.
  66.     friend class CInPlaceFrame;
  67.  
  68.     void SetMainContext(CAbstractCX *pContext);
  69.     void SetActiveContext(CAbstractCX *pContext);
  70. public:
  71.     virtual CAbstractCX *GetMainContext() const;
  72.     virtual CAbstractCX *GetActiveContext() const;
  73.     // For all those routines that think contexts are window contexts
  74.     virtual CWinCX *GetMainWinContext() const;
  75.     virtual CWinCX *GetActiveWinContext() const;
  76.     BOOL IsBackGroundPalette() {return     m_isBackgroundPalette;}
  77.     void SetIsBackgroundPalette(BOOL flag) {m_isBackgroundPalette = flag;}
  78.     BOOL RealizePalette(CWnd *pWnd, HWND hFocusWnd,BOOL background);
  79.  
  80.     void ClearContext(CAbstractCX *pGone);
  81.     
  82.     // Override this in Editors to return TRUE. Default = FALSE
  83.     virtual BOOL IsEditFrame();
  84.  
  85. protected:
  86.     IChrome    *m_pChrome;
  87.  
  88. private:
  89.  
  90.     BOOL m_bCanRestoreState;
  91.     int m_iSaveToolBarStyle;
  92.     BOOL m_bSaveToolBarVisible;
  93.     BOOL m_bSaveLocationBarVisible;
  94.     BOOL m_bSaveStarterBarVisible;
  95.  
  96. public:
  97.     void SaveBarState()    {
  98.         m_bCanRestoreState = TRUE;
  99.         m_bSaveToolBarVisible = m_pChrome->GetToolbarVisible(ID_NAVIGATION_TOOLBAR);
  100.         m_bSaveLocationBarVisible = m_pChrome->GetToolbarVisible(ID_LOCATION_TOOLBAR) ||
  101.                                     m_pChrome->GetToolbarVisible(ID_MESSENGER_INFOBAR);
  102.         m_bSaveStarterBarVisible = m_pChrome->GetToolbarVisible(ID_PERSONAL_TOOLBAR);
  103.     }
  104.     void RestoreBarState()    {
  105.         if(m_bCanRestoreState == TRUE)    {
  106.             m_pChrome->ShowToolbar(ID_NAVIGATION_TOOLBAR, m_bSaveToolBarVisible);
  107.             m_pChrome->ShowToolbar(ID_LOCATION_TOOLBAR, m_bSaveLocationBarVisible);
  108.             m_pChrome->ShowToolbar(ID_MESSENGER_INFOBAR, m_bSaveLocationBarVisible);
  109.             m_pChrome->ShowToolbar(ID_PERSONAL_TOOLBAR, m_bSaveStarterBarVisible);
  110.         }
  111.     }
  112.  
  113.     IChrome *GetChrome() const { return m_pChrome; }
  114.  
  115. //    You don't necessarily have to use these, but here they are.
  116. public:
  117.     int              m_iCSID;
  118.  
  119. //    Mostly shared prefs.
  120. public:
  121.     XP_Bool m_bShowToolbar;
  122.     XP_Bool m_bLocationBar;
  123.     XP_Bool m_bStarter;
  124.  
  125. //    Keep track of the find replace dialog.
  126. //    There can be only one.
  127. private:
  128.     CNetscapeFindReplaceDialog *m_pFindReplace;
  129. public:
  130.     BOOL CanFindReplace() const    {
  131.         return(m_pFindReplace == NULL);
  132.     }
  133.     void SetFindReplace(CNetscapeFindReplaceDialog *pDialog)    {
  134.         ASSERT(m_pFindReplace == NULL);
  135.         m_pFindReplace = pDialog;
  136.     }
  137.     CNetscapeFindReplaceDialog *GetFindReplace() {
  138.         return m_pFindReplace;
  139.     }
  140.     void ClearFindReplace()    {
  141.         m_pFindReplace = NULL;
  142.     }
  143.  
  144. //    Keeping track of the last active frame...
  145. protected:
  146.     static CPtrList m_cplActiveFrameStack;
  147.     static CPtrList m_cplActiveNotifyCBList;
  148.     static CPtrList m_cplActiveContextCBList;
  149.  
  150.     void SetAsActiveFrame();
  151.  
  152. public:
  153.     typedef void (*ActiveNotifyCB)(CFrameGlue *);
  154.     typedef void (*ActiveContextCB)(CFrameGlue *, CAbstractCX *);
  155.  
  156.     static void AddActiveNotifyCB( ActiveNotifyCB cb );
  157.     static void RemoveActiveNotifyCB( ActiveNotifyCB cb );
  158.     static void AddActiveContextCB( ActiveContextCB cb );
  159.     static void RemoveActiveContextCB( ActiveContextCB cb );
  160.  
  161.     static CFrameGlue *GetLastActiveFrame(MWContextType cxType = MWContextAny, int nFindEditor = FEU_FINDBROWSERONLY);
  162.  
  163.     //  bUseSaveInfo is true if custToolbar's save info field should be used to disregard frames if save info is FALSE
  164.     static CFrameGlue *GetLastActiveFrameByCustToolbarType(CString custToolbar, CFrameWnd *pCurrentFrame, BOOL bUseSaveInfo);
  165.     static CFrameGlue *GetBottomFrame(MWContextType cxType = MWContextAny, int nFindEditor = FEU_FINDBROWSERONLY);
  166.  
  167.     static int GetNumActiveFrames(MWContextType cxType = MWContextAny, int nFindEditor = FEU_FINDBROWSERONLY);
  168.     
  169. //    How to look up a frame window via context ID.
  170.  
  171.     static CFrameGlue *FindFrameByID(DWORD dwID, MWContextType cxType = MWContextAny);
  172.  
  173. //    A common command ID handler for all frames.
  174. //    Should be called by your derived OnCommand implementation.
  175. protected:
  176. // This is a quick hack until the full security advisor is done.
  177.     void SecurityDialog();
  178. public:
  179.     BOOL CommonCommand(UINT wParam, LONG lParam);
  180.  
  181. // Helper funtion to toggle WS_CLIPCHILDREN for a branch of the frame heirarchy
  182. protected:
  183.     CMapPtrToPtr * m_pClipChildMap;
  184. public:
  185.     void ClipChildren(CWnd *pWnd, BOOL bSet);
  186.  
  187. //    Pure virtual APIs, must be correctly defined by the deriving frame window class.
  188. public:
  189.     //    Access to the CFrameWnd pointer.
  190.     //    This could possibly return NULL if someone is not really a frame window, but
  191.     //        wants to act like one via deriving from CFrameGlue....
  192.     virtual CFrameWnd *GetFrameWnd() = 0;
  193.  
  194.     //    Updating of the history window, if around.
  195.     virtual void UpdateHistoryDialog() = 0;
  196.     virtual void SetSecurityStatus(int) {}
  197. };
  198.  
  199. class CNullFrame : public CFrameGlue    {
  200.     virtual CAbstractCX *GetMainContext() const;
  201.     virtual CAbstractCX *GetActiveContext() const;
  202.     virtual CFrameWnd *GetFrameWnd();
  203.     virtual void UpdateHistoryDialog();
  204. };
  205.  
  206. //    Global variables
  207. //
  208.  
  209. //    Macros
  210. //
  211.  
  212. //    Function declarations
  213. //
  214. CFrameGlue *GetFrame(MWContext *pContext);
  215.  
  216.  
  217. #endif // __FrameGlue_H
  218.