home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / cmd / winfe / gendoc.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  4.4 KB  |  149 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 __GenericDocument_H
  20. #define __GenericDocument_H
  21. // gendoc.h : header file
  22. //
  23.  
  24. /////////////////////////////////////////////////////////////////////////////
  25. // CGenericDoc document
  26.  
  27. class CNetscapeCntrItem;
  28. class CGenericDoc : public COleServerDoc
  29. {
  30.     //    We need some friends that can create us.
  31.     friend class CDCCX;
  32.     friend MWContext *FE_MakeGridWindow(MWContext *pOldContext, void *hist_list, void *pHistory, int32 lX, int32 lY, int32 lWidth, int32 lHeight, char *pUrlStr, char *pWindowName, int8 iScrollType);
  33.  
  34. public:
  35.     CGenericDoc();           // protected constructor used by dynamic creation
  36.     DECLARE_DYNCREATE(CGenericDoc)
  37.  
  38. //    How to set the document template.
  39. public:
  40.     void SetDocTemplate(CDocTemplate *pTemplate)    {
  41.         m_pDocTemplate = pTemplate;
  42.     }
  43.  
  44. //    Context access, every one of these docs should have one.
  45. protected:
  46.     CDCCX *m_pContext;
  47. public:
  48.     void SetContext(CDCCX *pContext)    {
  49.         m_pContext = pContext;
  50.     }
  51.     CDCCX *GetContext() const    {
  52.         return(m_pContext);
  53.     }
  54.     void ClearContext()    {
  55.         TRACE("Clearing doc context\n");
  56.         SetContext(NULL);
  57.     }
  58.  
  59. //  Embed handling
  60. public:
  61.     virtual void GetEmbedSize(MWContext *pContext, LO_EmbedStruct *pLayoutData, NET_ReloadMethod bReload);
  62.     virtual void FreeEmbedElement(MWContext *pContext, LO_EmbedStruct *pLayoutData);
  63.  
  64. //    OLE server handling
  65. public:
  66.     CNetscapeSrvrItem *GetEmbeddedItem()    {
  67.         return((CNetscapeSrvrItem *)COleServerDoc::GetEmbeddedItem());
  68.     }
  69.  
  70. //    OLE server extension to allow document and server item
  71. //        to minimally function without a context being
  72. //        present.
  73. protected:
  74.     CString m_csEphemeralHistoryAddress;
  75. public:
  76.     virtual void CacheEphemeralData();
  77.  
  78. //    Helpers to resolve between ephemeral and actual data.
  79. public:
  80.     void GetContextHistoryAddress(CString &csRetval);
  81.  
  82.  
  83. private:
  84. void GetPluginRect(MWContext *pContext,
  85.                    LO_EmbedStruct *pLayoutData,
  86.                    CRect &rect);
  87.  
  88. //    Way to disable closing of the owning frame window.
  89. private:
  90.     BOOL m_bCanClose;
  91. public:
  92.     void EnableClose(BOOL bEnable = TRUE);
  93.     BOOL CanClose();
  94.  
  95. //  Serialize flags which aid when and when not to serialize
  96. //  when using the MFC framework for ole server stuff.
  97. private:
  98.     CString m_csOpenDocumentFile;
  99.     BOOL m_bOpenDocumentFileSet;
  100.  
  101. //  Cache sizing to avoid wild resizes when an OLE server.
  102. public:
  103.     CSize m_csViewExtent;
  104.     CSize m_csDocumentExtent;
  105.  
  106. // Overrides
  107.     // ClassWizard generated virtual function overrides
  108.     //{{AFX_VIRTUAL(CGenericDoc)
  109. protected:
  110.     virtual BOOL OnOpenDocument(const char *pszPathName);
  111.     virtual BOOL CanCloseFrame(CFrameWnd *pFrame);
  112.     virtual BOOL OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo);
  113.     virtual COleServerItem *OnGetEmbeddedItem();
  114.     virtual void OnCloseDocument();
  115.     //}}AFX_VIRTUAL
  116.  
  117.     virtual void OnShowControlBars( CFrameWnd *pFrameWnd, BOOL bShow );
  118.  
  119. public:
  120.     virtual void OnDeactivateUI( BOOL bUndoable );
  121.  
  122. // Implementation
  123. public:
  124.     virtual ~CGenericDoc();
  125.     virtual void Serialize(CArchive& ar);   // overridden for document i/o
  126.  
  127. #ifdef _DEBUG
  128.     virtual void AssertValid() const;
  129.     virtual void Dump(CDumpContext& dc) const;
  130. #endif
  131.     virtual BOOL OnSaveDocument( LPCTSTR lpszPathName );
  132.     BOOL DoSaveFile( CNetscapeCntrItem* pItem, LPCTSTR lpszPathName);
  133.  
  134.  
  135. private:
  136. BOOL CGenericDoc::PromptForFileName(CNetscapeCntrItem* pItem, CString& lpszPathName, CString &orgFileName, BOOL useDefaultDocName);
  137.  
  138.     // Generated message map functions
  139. protected:
  140.     //{{AFX_MSG(CGenericDoc)
  141.     afx_msg void OnEditCopy();
  142.     afx_msg void OnOleUpdate();
  143.     afx_msg void OnUpdateOleUpdate(CCmdUI* pCmdUI);
  144.     //}}AFX_MSG
  145.     DECLARE_MESSAGE_MAP()
  146. };
  147.  
  148. #endif // __GenericDocument_H
  149.