home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / cmd / winfe / netsvw.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  10.5 KB  |  301 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. // netsvw.h : interface of the CNetscapeView class
  20. //
  21. /////////////////////////////////////////////////////////////////////////////
  22.  
  23. #ifndef MOVIEW_H
  24. #define MOVIEW_H
  25.  
  26. // if user moves mouse more than this distance between button down and
  27. //  button up do not follow a link if it's over one
  28. #define CLICK_THRESHOLD 2 
  29.  
  30. #define NETSCAPE_IMAGE_FORMAT "Netscape Image Format"
  31. #define NETSCAPE_EDIT_FORMAT  "NETSCAPE_EDITOR"
  32.  
  33. // Number of formats registered for m_pClipboardFormats array
  34.  
  35. #ifdef _IMAGE_CONVERT
  36. #define MAX_CLIPBOARD_FORMATS   12
  37. #else
  38. #define MAX_CLIPBOARD_FORMATS   11
  39. #endif //_IMAGE_CONVERT
  40.  
  41. // Types of items being dragged over us
  42. enum FEDragType {
  43.     FE_DRAG_UNKNOWN,
  44.     FE_DRAG_TEXT,
  45.     FE_DRAG_HTML,
  46.     FE_DRAG_TABLE,
  47.     FE_DRAG_LINK,
  48.     FE_DRAG_IMAGE,
  49.     FE_DRAG_VCARD,
  50.     FE_DRAG_FORM_ELEMENT
  51.     // Add more as we dream them up!
  52. };
  53.  
  54. /////////////////////////////////////////////////////////////////////////////
  55. // Mostly default behavior, but override the type of cursor used 
  56. //   during drag and drop
  57. //
  58. class CViewDropSource : public COleDropSource
  59. {
  60. public:
  61. //Construction
  62.     CViewDropSource(UINT nDragType = 0);
  63.     UINT  m_nDragType;
  64.     SCODE GiveFeedback(DROPEFFECT dropEffect);
  65. };
  66.  
  67. /////////////////////////////////////////////////////////////////////////////
  68. // 
  69. class CViewDropTarget : public COleDropTarget
  70. {
  71. public:
  72. //Construction
  73.     CViewDropTarget();
  74.     BOOL        OnDrop(CWnd *, COleDataObject *, DROPEFFECT, CPoint);
  75.     DROPEFFECT  OnDragEnter(CWnd *, COleDataObject *, DWORD, CPoint);
  76.     DROPEFFECT  OnDragOver(CWnd *, COleDataObject *, DWORD, CPoint);
  77.     void        OnDragLeave(CWnd *);
  78. private:
  79.     int m_nIsOKDrop;
  80. };
  81.  
  82. #ifdef EDITOR
  83. // Implemented in edview.cpp
  84. // Call when we MUST save a new document,
  85. //      such as before Printing or calling an external Editor
  86. // Return TRUE if: 
  87. //      1. User saved the document
  88. //      2. User didn't want to save, and doc already exists (not new)
  89. //      3. Doc exists but is not dirty
  90. //      4. We are not a Page Composer (allows calling without testing for EDT_IS_EDITOR() first )
  91. //      5. We are a message Message Compose window
  92. // Note: We must always save a new/untitled document, even if not dirty
  93. BOOL FE_SaveDocument(MWContext * pMWContext);
  94.  
  95. // Call this instead of forcing file saving by making 
  96. //  a temporary file from current page. This filename
  97. //  replaces the pUrl->address in struct passed in.
  98. //  If return is FALSE, then there was an error - don't continue
  99. BOOL FE_PrepareTempFileUrl(MWContext * pMWContext, URL_Struct *pUrl);
  100. #endif // EDITOR
  101.  
  102. ////////////////////////////////////////////////////////////////////////////////
  103. // Main Document view
  104. // All stuff specific to the main document viewing area (i.e. NOT ledge stuff)
  105. //
  106. class CPrintCX;
  107.  
  108. class CNetscapeView : public CGenericView
  109. {
  110. //    Properties
  111. public:
  112.    CWnd * m_pChild;
  113.     int  m_nBDownX, m_nBDownY;    // pixel coords of button down event, LFB
  114.  
  115.     // Right mouse stuff
  116.     POINT m_ptRBDown;            // coords of right button down, not to confuse with LFB
  117.     LO_Element*    m_pRBElement;    // The layout element we're over on a RBD.
  118.     CString m_csRBLink;            // The link that we're over on a RBD.
  119.     CString m_csRBImage;        // The image that we're over on a RBD.
  120.     CString m_csRBEmbed;        // The embed that we're over on a RBD.
  121. #ifdef LAYERS
  122.     CL_Layer *m_pLayer;            // The layer that we're over 
  123. #endif
  124.  
  125.     CViewDropTarget * m_pDropTarget;
  126.     int m_SubView;  // Are we the top ledge, main view or bottom ledge
  127.  
  128. #ifdef EDITOR
  129.     // Array of clipboard formats accepted for pasting into document
  130.     // We put here instead of Editor's view because we need to drag 
  131.     //   FROM a Browser window
  132.     UINT * m_pClipboardFormats;
  133.     
  134.     CLIPFORMAT   m_cfEditorFormat;
  135.     CLIPFORMAT   m_cfBookmarkFormat;
  136.     CLIPFORMAT   m_cfImageFormat;
  137. #endif
  138.     // Progress dialog used for Editor Publishing and 
  139.     //   FTP/HTTP upload
  140.     CSaveFileDlg*  m_pSaveFileDlg;    
  141.  
  142. public:
  143.     static void CopyLinkToClipboard(HWND hWnd, CString url);
  144.  
  145.  
  146. protected: // create from serialization only
  147.     DECLARE_DYNCREATE(CNetscapeView)
  148.     CNetscapeView();
  149.     ~CNetscapeView();
  150.  
  151. //    Our context, a Grid.
  152. //    Some grid friends (creation/destruction).
  153. //    It isn't setup until the call to SetContext.
  154. protected:
  155.     friend MWContext *FE_MakeGridWindow(MWContext *pOldContext, int32 lX, int32 lY, int32 lWidth, int32 lHeight, char *pUrlStr, char *pWindowName);
  156.     friend void FE_FreeGridWindow(MWContext *pContext);
  157.  
  158. public:
  159.     HDC GetContextDC()    {
  160.         if(GetContext())    {
  161.             return(GetContext()->GetContextDC());
  162.         }
  163.         return(NULL);
  164.     }
  165.  
  166. // Operations
  167. protected:
  168.     virtual void OnInitialUpdate();    //    Called first time after construct
  169.  
  170.     virtual void OnActivateFrame(UINT nState, CFrameWnd* /*pFrameWnd*/);
  171.     // Focus management (for internationalization)
  172.     virtual void OnActivateView(BOOL bActivate, CView* pActivateView, CView* pDeactiveView);
  173.  
  174. // Implementation
  175. public:
  176.  
  177.     //    Print preview.
  178.     CPrintCX *m_pPreviewContext;
  179.     void OnFilePrintPreview();
  180.     void OnEndPrintPreview(CDC *pDC, CPrintInfo *pInfo, POINT pXY,
  181.         CPreviewView *pView);
  182.     BOOL DoPrintPreview(UINT nIDResource, CView *pPrintView,
  183.         CRuntimeClass *pPreviewViewClass, CPrintPreviewState *pState);
  184.     void OnPrint(CDC *pDC, CPrintInfo *pInfo);
  185.     BOOL OnPreparePrinting(CPrintInfo *pInfo);
  186.  
  187.     virtual BOOL PreCreateWindow(CREATESTRUCT & cs);
  188.     
  189. #ifdef _DEBUG
  190.     virtual void AssertValid() const;
  191.     virtual void Dump(CDumpContext& dc) const;
  192. #endif
  193.  
  194.     void SetChild ( CWnd * pChild ) { m_pChild = pChild; }
  195.  
  196. #ifdef EDITOR
  197.     BOOL   m_bIsEditor;
  198.     inline BOOL IsEditor() { return m_bIsEditor; }
  199.  
  200.     // Get editor from preferences app via pPrefName
  201.     // If no default, get from Open File Dialog (use nIDCaption for dialog caption)
  202.     void CNetscapeView::SpawnExternalEditor(MWContext *pMWContext, const char *pPrefName, char *pURL, UINT nIDCaption);
  203.  
  204.     // Load an image in a user-designated editor (saved in preferences)
  205.     void EditImage(char *pImage);  
  206. #endif
  207.  
  208. #ifdef LAYERS
  209.         void GetLogicalPoint(CPoint cpPoint, long *pLX, long *pLY);
  210.     LO_Element *GetLayoutElement(CPoint cpPoint, CL_Layer *layer);
  211.     virtual BOOL OnRButtonDownForLayer(UINT nFlags, CPoint& point, 
  212.                        long lX, long lY, CL_Layer *layer);
  213. #else
  214.     LO_Element *GetLayoutElement(CPoint cpPoint);
  215. #endif /* LAYERS */
  216.  
  217.     CString GetAnchorHref(LO_Element *pElement);
  218.     CString GetImageHref(LO_Element *pElement);
  219.     CString GetEmbedHref(LO_Element *pElement);
  220.  
  221.     void SetSubView(int subView)    {
  222.         m_SubView = subView;
  223.     }
  224.  
  225.     CGenericDoc *GetDocument();
  226.  
  227. #ifdef EDITOR
  228.     virtual void OnLocalPopup();
  229. #endif /* EDITOR */
  230.     
  231. protected:
  232.     // populate the given menu with items appropritate for being 
  233.     //   over the given LO_Element
  234.     void CreateWebPopup(CMenu * pMenu, LO_Element * pElement, CL_Layer *layer);
  235.     void CreateMessagePopup(CMenu * pMenu, LO_Element * pElement, CL_Layer *layer);
  236.     BOOL AddLinkToPopup(CMenu * pMenu, LO_Element * pElement, BOOL bBrowser);
  237.     BOOL AddEmbedToPopup(CMenu * pMenu, LO_Element * pElement, CL_Layer *layer, BOOL bAddSeparator);
  238.     BOOL AddClipboardToPopup(CMenu * pMenu, LO_Element * pElement, BOOL bAddSeparator);
  239.     BOOL AddSaveItemsToPopup(CMenu * pMenu, LO_Element * pElement, CL_Layer *layer, BOOL bAddSeparator);
  240.     void AddBrowserItemsToPopup(CMenu * pMenu, LO_Element * pElement, CL_Layer *layer);
  241.     void AddNavigateItemsToPopup(CMenu *pMenu, LO_Element * pElement, CL_Layer *layer);
  242.     void AddViewItemsToPopup(CMenu * pMenu, MWContext *pContex, LO_Element * pElement);
  243. // Used by OnPopupAddLinkToBookmarks and OnPopupInternetShortcut
  244.  
  245.     void CreateTextAndAnchor(CString &, CString &);
  246.  
  247. // Generated message map functions
  248. protected:
  249.     //{{AFX_MSG(CNetscapeView)
  250.    afx_msg void OnSize ( UINT nType, int cx, int cy );
  251.     afx_msg void OnSetFocus(CWnd *);
  252.     afx_msg void OnPrepareDC(CDC *pDC, CPrintInfo * pInfo /* = NULL */);
  253.     afx_msg void OnDeactivateEmbed();
  254.     afx_msg void OnWindowPosChanged(WINDOWPOS * wndpos);
  255.     afx_msg void OnUpdateNavigateRepaint(CCmdUI* pCmdUI);
  256.     afx_msg void OnMove(int x, int y);
  257.     afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
  258.     afx_msg void OnCopyImageToClipboard();
  259.     afx_msg void OnPopupLoadLink();
  260.     afx_msg void OnPopupAddLinkToBookmarks();
  261.     afx_msg void OnPopupLoadLinkNewWindow();
  262.     afx_msg void OnPopupLoadFrameNewWindow();
  263.     afx_msg void OnPopupSaveLinkContentsAs();
  264.     afx_msg void OnPopupCopyLinkToClipboard();
  265.     afx_msg void OnPopupLoadImage();
  266.     afx_msg void OnPopupSaveImageAs();
  267.     afx_msg void OnPopupCopyImageLocationToClipboard();
  268.     afx_msg void OnPopupLoadImageInline();
  269.     afx_msg void OnPopupActivateEmbed();
  270.     afx_msg void OnPopupSaveEmbedAs();
  271.     afx_msg void OnCopyCurrentURL();
  272.     afx_msg void OnPopupCopyEmbedLocationToClipboard();
  273.     afx_msg void OnPopupCopyEmbedToClipboard();
  274.     afx_msg void OnPopupSetAsWallpaper();
  275.     afx_msg void OnNavigateRepaint();
  276.     afx_msg    BOOL OnQueryNewPalette(); 
  277.     afx_msg void OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags);
  278.     afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
  279.     afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
  280.     afx_msg void OnPopupInternetShortcut();
  281.     afx_msg void OnPopupMailTo();
  282.  
  283.     // afx_msg void OnDropFiles( HDROP hDropInfo );
  284.     //}}AFX_MSG
  285. #ifdef EDITOR
  286.     afx_msg void OnCanInteract(CCmdUI* pCmdUI);
  287.     afx_msg void OnEditSource();
  288.     afx_msg void OnPopupEditImage();
  289.     afx_msg void OnPopupLoadLinkInEditor();
  290. #endif
  291.     DECLARE_MESSAGE_MAP()
  292. };
  293.  
  294. #ifdef _DEBUG_HUH_JEM  // debug version in netsvw.cpp
  295. inline CNetscapeDoc* CNetscapeView::GetDocument()
  296.    { return (CNetscapeDoc*) m_pDocument; }
  297. #endif
  298. /////////////////////////////////////////////////////////////////////////////
  299.  
  300. #endif //MOVIEW_H
  301.