home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / cmd / winfe / genframe.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  14.0 KB  |  411 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 __GenericFrame_H
  20. #define __GenericFrame_H
  21.  
  22. // genframe.h : header file
  23. //
  24. #include "frameglu.h"
  25. #include "htrdf.h"
  26.  
  27. #define WIN_ANIMATE_ICON_TIMER    4
  28. #define MSG_TASK_NOTIFY            (WM_USER + 1)
  29.  
  30. // Longest menu item length for Composer's last-edited history submenus
  31. #define MAX_MENU_ITEM_LENGTH    45
  32.  
  33. //cmanske: As much as I dislike assume fixed menu positions,
  34. //  it infinitely simplifies finding submenus when building menus at runtime
  35. enum {
  36.     ED_MENU_FILE,
  37.     ED_MENU_EDIT,
  38.     ED_MENU_VIEW,
  39.     ED_MENU_INSERT,
  40.     ED_MENU_FORMAT,
  41.     ED_MENU_TABLE,
  42.     ED_MENU_TOOLS,
  43.     ED_MENU_COMMUNICATOR,
  44.     ED_MENU_HELP
  45. };
  46.  
  47. // Load a URL into a new Browser window
  48. // This simply creates the URL struct and calls CFE_CreateNewDocWindow
  49. MWContext * wfe_CreateNavigator(char * pURL = NULL);
  50. /////////////////////////////////////////////////////////////////////////////
  51. // CGenericFrame frame
  52.  
  53. class CNSGenFrame : public CFrameWnd
  54. {
  55.     DECLARE_DYNCREATE(CNSGenFrame)
  56. public:
  57.     CNSNavFrame* GetDockedNavCenter();
  58.     virtual BOOL AllowDocking();
  59. protected:
  60.     afx_msg void OnActivate( UINT nState, CWnd* pWndOther, BOOL bMinimized);
  61.     DECLARE_MESSAGE_MAP()
  62. };
  63.  
  64. class CGenericFrame : public CNSGenFrame, public CFrameGlue
  65. {
  66.     DECLARE_DYNCREATE(CGenericFrame)
  67. protected:
  68.     CGenericFrame();           // protected constructor used by dynamic creation
  69.     BOOL m_bPreCreated;
  70.  
  71.     CTreeMenu *m_pBookmarksMenu;
  72.     CTreeMenu *m_pFileBookmarkMenu;
  73.     CTreeItemList *m_BookmarksGarbageList;
  74.     CTreeItemList *m_OriginalBookmarksGarbageList;
  75.     CBitmap *m_pBookmarkBitmap;
  76.     CBitmap *m_pBookmarkFolderBitmap;
  77.     CBitmap *m_pBookmarkFolderOpenBitmap;
  78.  
  79.     CTreeMenu* m_pCachedTreeMenu;
  80.     int m_nCachedStartPoint;
  81.  
  82.     HT_Pane m_BookmarkMenuPane; // Added for Aurora (Dave Hyatt 2/12/97)
  83.  
  84.     void BuildBookmarkMenu(CTreeMenu* pMenu, HT_Resource pRoot, int nStart = 0); 
  85.     
  86.     void BuildFileBookmarkMenu(CTreeMenu* pMenu, HT_Resource pRoot);
  87.     void BuildDirectoryMenu(CMenu* pMenu);
  88.     
  89.     //Returns TRUE if pFolder is changed, FALSE otherwise
  90.     virtual BOOL FileBookmark(HT_Resource pFolder);
  91.     void InitFileBookmarkMenu(void);
  92.     void LoadBookmarkMenuBitmaps(void);
  93.  
  94. // Menu Map 
  95. // Everything below is for the case where a frame wants to dynamically load its
  96. // menus.  This is done to save user resources in Win16.
  97. protected:
  98. #ifdef _WIN32
  99.     CMapPtrToPtr *m_pMenuMap;
  100. #else
  101.     CMapWordToPtr *m_pMenuMap;
  102. #endif
  103.  
  104.     void AddToMenuMap(int nIndex, UINT nID);
  105.     void LoadFrameMenu(CMenu *pPopup, UINT nIndex);
  106.     void DeleteFrameMenu(HMENU hMenu);
  107.     void DeleteMenuMapMenus(void);
  108.     void DeleteMenuMapIDs(void);
  109.  
  110.  
  111. public:
  112.     CTreeMenu * GetBookmarksMenu(void) { return m_pBookmarksMenu; }
  113.     void FinishMenuExpansion(HT_Resource pRoot); 
  114.  
  115.  
  116. #ifdef XP_WIN32
  117.     // jliu added the following to support CJK caption print
  118.     virtual int16 GetTitleWinCSID();
  119. #endif
  120.  
  121.  
  122. public:
  123.     // ugh this should really be private
  124.     CGenericFrame  * m_pNext;  // the next frame in the theApp.m_pFrameList
  125.     // Use only by editor to avoid double-prompting for saving changes
  126.     //  when we call CGenericDoc::CanCloseFrame followed by frame's OnClose()
  127.     BOOL m_bSkipSaveEditChanges;
  128.     BOOL m_isClosing;
  129.     BOOL m_DockOrientation;
  130.  
  131. //    CFrameGlue required overrides
  132. public:
  133.     virtual CFrameWnd *GetFrameWnd();
  134.     virtual void UpdateHistoryDialog();
  135.     void         BuildHelpMenu(CMenu * pMenu);
  136.  
  137.     // override this only if you want to
  138.     virtual void OnConstructWindowMenu ( CMenu * pMenu );
  139.     void        OnSaveConfiguration();
  140.  
  141. // Attributes
  142. public:
  143.     // Used for bookmark menu items and history menu items
  144.     int                m_nBookmarkItems;    // current number of bookmark menu items
  145.     int                m_nFileBookmarkItems;
  146. #ifdef XP_WIN32
  147.     CMapPtrToPtr*    m_pSubmenuMap;      // HMENU -> BM_Entry*
  148. #else
  149.     CMapWordToPtr*    m_pSubmenuMap;      // HMENU -> BM_Entry*
  150. #endif
  151.  
  152. #ifdef XP_WIN32
  153.     CMapPtrToPtr*    m_pFileSubmenuMap;      // HMENU -> BM_Entry*
  154. #else
  155.     CMapWordToPtr*    m_pFileSubmenuMap;      // HMENU -> BM_Entry*
  156. #endif
  157.  
  158.     CMapWordToPtr*    m_pHotlistMenuMap;  // command ID -> URL and
  159.                                         // command ID -> History_Entry*
  160.  
  161. //    We may or may not allow the window to resize.
  162. private:
  163.     BOOL m_bCanResize;
  164.     CRect m_crMinMaxRect;
  165.     BOOL m_bZOrderLocked;
  166.     BOOL m_bBottommost;
  167.     BOOL m_bDisableHotkeys;
  168.     DWORD m_wAddedExStyles;
  169.     DWORD m_wRemovedExStyles;
  170.  
  171. #ifdef XP_WIN32
  172.     // jliu added the following to support CJK caption print
  173.     void SetupCapFont( int16 csid, BOOL force = FALSE );
  174.     UINT  capStyle;
  175.     BOOL  m_bActive;
  176.     CFont hCapFont;
  177.     int16 m_csid;                // WinCSID of current document
  178. #endif
  179.  
  180.     HWND  m_hPopupParent;
  181.     BOOL  m_bConference;
  182.  
  183.  
  184. public:
  185.     void EnableResize(BOOL bEnable = TRUE);
  186.     BOOL CanResize(){ return m_bCanResize; }
  187.     void SetZOrder(BOOL bZLock = FALSE, BOOL bBottommost = FALSE);
  188.     BOOL IsZOrderLocked(){ return m_bZOrderLocked; }
  189.     BOOL IsBottommost(){ return m_bBottommost; }
  190.     void DisableHotkeys(BOOL bDisable = FALSE);
  191.     BOOL HotkeysDisabled(){ return m_bDisableHotkeys; }
  192. #ifdef WIN32
  193.     void SetExStyles(DWORD wAddedExStyles, DWORD wRemovedExStyles);
  194.     DWORD GetRemovedExStyles();
  195. #endif
  196.     void SetAsPopup(HWND hPopupParent);
  197.  
  198. // Operations
  199. public:
  200.  
  201. //    Some static public data, initialized in genframe.cpp
  202. //  used to offset frame windows from one another
  203.     static int      m_FirstFrame;
  204.  
  205. // Overrides
  206.     // ClassWizard generated virtual function overrides
  207.     //{{AFX_VIRTUAL(CGenericFrame)
  208.     public:
  209.     virtual void RecalcLayout( BOOL bNotify = TRUE );
  210.     virtual BOOL PreTranslateMessage(MSG *pMsg);
  211.     virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
  212.     virtual BOOL OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo);
  213.     protected:
  214.     virtual BOOL OnCommand(WPARAM wParam, LPARAM lParam);
  215.     //}}AFX_VIRTUAL
  216.  
  217. public:
  218.     // assorted people can cause us to open windows.  Make these public so we
  219.     //   can try to localize the functionality
  220.     afx_msg void OnOpenMailWindow();
  221.     afx_msg void OnOpenInboxWindow();
  222.     afx_msg void OnOpenNewsWindow();
  223.     afx_msg void OnToolsWeb();
  224.     afx_msg void OnOpenComposerWindow(); // Implemented in edframe.cpp
  225.  
  226.  
  227.     afx_msg void OnToggleEncoding(UINT nID);
  228.     afx_msg void OnUpdateEncoding(CCmdUI* pCmdUI);
  229.  
  230. // Implementation
  231. protected:
  232.  
  233.     virtual ~CGenericFrame();
  234.     virtual void GetMessageString( UINT nID, CString& rMessage ) const;
  235.  
  236.     // Generated message map functions
  237.     afx_msg void OnEnterIdle(UINT nWhy, CWnd* pWho );
  238.     afx_msg void OnInitMenuPopup(CMenu * pPopup, UINT nIndex, BOOL bSysMenu);
  239.     afx_msg void OnMenuSelect( UINT nItemID, UINT nFlags, HMENU hSysMenu );
  240.     afx_msg void OnMeasureItem(int nIDCtl, LPMEASUREITEMSTRUCT lpMeasureItemStruct);
  241.     afx_msg LRESULT OnMenuChar( UINT nChar, UINT nFlags, CMenu* pMenu );
  242.     afx_msg LRESULT OnSetMessageString(WPARAM wParam, LPARAM lParam);
  243.     afx_msg void OnClose();
  244.     afx_msg void OnDestroy();
  245.     afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
  246.     afx_msg void OnSysColorChange();
  247.     afx_msg BOOL OnQueryNewPalette();
  248.     afx_msg void OnPaletteChanged(CWnd* pFocusWnd);
  249.  
  250.     afx_msg void OnNewFrame();
  251.     afx_msg void OnUpdateNewFrame(CCmdUI* pCmdUI);
  252.     afx_msg void OnFileOpenurl();
  253.     afx_msg void OnUpdateFileOpenurl(CCmdUI* pCmdUI);
  254.     afx_msg void OnHotlistAddcurrenttohotlist();
  255.     afx_msg void OnUpdateHotlistAddcurrenttohotlist(CCmdUI* pCmdUI);
  256.     afx_msg void OnHotlistAddcurrenttotoolbar();
  257.     afx_msg void OnUpdateHotlistAddcurrenttotoolbar(CCmdUI* pCmdUI);
  258.     afx_msg void OnUpdateOpenMailWindow(CCmdUI* pCmdUI);
  259.     afx_msg void OnUpdateOpenNewsWindow(CCmdUI* pCmdUI);
  260.     afx_msg void OnUpdateTaskbar(CCmdUI *pCmdUI);
  261.     afx_msg void OnAbout();
  262.     afx_msg void OnDocumentTop();
  263.     afx_msg void OnDocumentBottom();
  264.     afx_msg void OnFishCam(); 
  265.     afx_msg void OnShowBookmarkWindow();
  266.     afx_msg void OnShowAddressBookWindow();
  267. #ifdef JAVA
  268.     afx_msg void OnToggleJavaConsole();
  269.     afx_msg void OnUpdateJavaConsole(CCmdUI* pCmdUI);
  270. #endif
  271.     afx_msg void OnSecurity();
  272.     afx_msg void OnUpdateSecurity(CCmdUI *pCmdUI);
  273.     afx_msg void OnViewCommandToolbar();
  274.     afx_msg void OnUpdateViewCommandToolbar(CCmdUI* pCmdUI);
  275.     afx_msg void OnViewLocationToolbar();
  276.     afx_msg void OnUpdateViewLocationToolbar(CCmdUI* pCmdUI);
  277.     afx_msg void OnViewCustomToolbar();
  278.     afx_msg void OnUpdateViewCustomToolbar(CCmdUI* pCmdUI);
  279.     afx_msg void OnViewNavCenter();
  280.     afx_msg void OnUpdateViewNavCenter(CCmdUI* pCmdUI);
  281.     afx_msg void OnUpdatePlaces(CCmdUI* pCmdUI);
  282.     afx_msg void OnUpdateCustomizeToolbar(CCmdUI *pCmdUI);
  283.     afx_msg void OnCustomizeToolbar();
  284.     afx_msg void OnIncreaseFont();
  285.     afx_msg void OnDecreaseFont();
  286.     afx_msg void OnGoHistory();
  287.     afx_msg void OnFileMailNew();
  288.     afx_msg void OnTaskbar();
  289.     afx_msg void OnUpdateLiveCall(CCmdUI *pCmdUI);
  290.     afx_msg void OnLiveCall();
  291.     afx_msg void OnCalendar();
  292.     afx_msg void OnIBMHostOnDemand();
  293.      afx_msg void OnNetcaster();
  294.     afx_msg void OnAim();
  295.     afx_msg void OnDisplayPreferences();
  296.     afx_msg void OnPrefsGeneral();
  297.     afx_msg void OnPrefsMailNews();
  298.     afx_msg void OnPrefsNetwork();
  299.     afx_msg void OnPrefsSecurity();
  300.     afx_msg void OnAnimationBonk();
  301.     afx_msg void OnUpdateFileRoot(CCmdUI* pCmdUI);
  302.     afx_msg void OnGoOffline();
  303.     afx_msg void OnUpdateGoOffline(CCmdUI* pCmdUI);
  304.     afx_msg void OnDoneGoingOffline();
  305. #ifdef FORTEZZA
  306.     afx_msg void OnStartFortezzaCard();
  307.     afx_msg void OnStartFortezzaChange();
  308.     afx_msg void OnStartFortezzaView();
  309.     afx_msg void OnDoFortezzaInfo();
  310.     afx_msg void OnDoFortezzaLog();
  311. #endif
  312.     afx_msg void OnFrameExit();
  313.     afx_msg void OnSetFocus(CWnd* pOldWnd);
  314.     afx_msg void OnWindowPosChanged(WINDOWPOS* lpwndpos);
  315.     afx_msg void OnWindowPosChanging(WINDOWPOS* lpwndpos);
  316.     afx_msg void OnSize(UINT nType, int cx, int cy);
  317.     afx_msg void OnSizing(UINT nSide, LPRECT lpRect);
  318.     afx_msg void OnNextWindow();
  319.     afx_msg void OnSaveOptions();
  320.     afx_msg LRESULT OnFindReplace(WPARAM wParam, LPARAM lParam);
  321.     afx_msg LRESULT OnHelpMsg(WPARAM wParam, LPARAM lParam);
  322.     afx_msg void OnMove(int x, int y);
  323.     afx_msg void OnFilePageSetup();
  324.     afx_msg void OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI);
  325.     afx_msg LONG OnTaskNotify(WPARAM wParam, LPARAM lParam);
  326.     afx_msg void OnShowAdvanced();
  327.     afx_msg void OnUpdateShowAdvanced( CCmdUI *pCmdUI );
  328.     afx_msg void OnHelpMenu();
  329.     afx_msg void OnLDAPSearch();
  330.     afx_msg void OnPageFromWizard();
  331. #ifdef EDITOR
  332.     afx_msg void OnEditNewBlankDocument();
  333.     afx_msg void OnActivateSiteManager();
  334.     afx_msg void OnUpdateActivateSiteManager(CCmdUI* pCmdUI);
  335.     // Response to Registered messages to detect 1st instance
  336.     afx_msg LRESULT OnNetscapeGoldIsActive(WPARAM wParam, LPARAM lParam);
  337.     // Response to Registered messages to open Editor or Navigator
  338.     //  from attempted 2nd instance or Site Manager
  339.     afx_msg LRESULT OnOpenEditor(WPARAM wParam, LPARAM lParam);
  340.     afx_msg LRESULT OnOpenNavigator(WPARAM wParam, LPARAM lParam);
  341. #ifdef XP_WIN32
  342.     afx_msg LRESULT OnSiteMgrMessage(WPARAM wParam, LPARAM lParam);
  343. #endif
  344.     // These are hooked up to menu commands...
  345.     afx_msg void OnNavigateToEdit();
  346.     afx_msg void OnEditFrame();
  347.     // ...and call this after setting appropriate m_iLoadUrlEditorState
  348.     void OpenEditorWindow(int iStyle);
  349.     
  350.     // This is used for all of above - prevent interaction
  351.     //  with menus when no context, edit buffer, etc exists
  352.     afx_msg void OnUpdateCanInteract(CCmdUI* pCmdUI);
  353.     afx_msg void OnUpdateEditFrame(CCmdUI* pCmdUI);
  354.     afx_msg void OnEditNewDocFromTemplate();
  355. #endif
  356.  
  357.  
  358. #ifdef _WIN32
  359.     afx_msg LONG OnHackedMouseWheel(WPARAM wParam, LPARAM lParam);
  360.     // jliu added the following to support CJK caption print
  361.     afx_msg void OnNcPaint();
  362.     afx_msg BOOL OnNcActivate( BOOL );
  363.     afx_msg LRESULT OnSetText(WPARAM wParam, LPARAM lParam);
  364.     afx_msg LRESULT OnSettingChange(WPARAM, LPARAM);
  365. #endif
  366.     afx_msg void OnActivate( UINT nState, CWnd* pWndOther, BOOL bMinimized);
  367. #ifdef DEBUG_WHITEBOX
  368.     afx_msg void OnWhiteBox();
  369. #endif
  370.     DECLARE_MESSAGE_MAP()
  371.  
  372. #ifdef EDITOR
  373. public:
  374.     // Load a URL into a new edit window,
  375.     //  OR the existing window if bNewWindow is FALSE
  376.     //     (used only when Composer is first window)
  377.     void LoadUrlEditor(char * pURL = NULL,
  378.                        BOOL bNewWindow = TRUE,
  379.                        int iLoadStyle = 0, 
  380.                        MWContext * pCopyHistoryContext = NULL);
  381.  
  382.     // Called from Edit view only after CheckAndSaveDocument
  383.     void OpenNavigatorWindow(MWContext * pMWContext);
  384.  
  385.     // Currently used only when canceling an already-loaded URL
  386.     //   in editor and user doesn't want to save to disk
  387.     //   (replaces editor with a browser with the same URL)
  388.     void EditToNavigate(MWContext * pEditContext, BOOL bNewDocument );
  389.     
  390.     // Put all Composer-only code here - called only from CGenericFrame::OnMenuSelect()
  391.     void OnMenuSelectComposer(UINT nItemID, UINT nFlags, HMENU hSysMenu);
  392.     BOOL m_bCloseFrame;
  393.  
  394. #endif
  395.  
  396.     virtual void RefreshNewEncoding(int16 csid, BOOL bIgnore=TRUE);
  397. };
  398.  
  399. #ifdef EDITOR
  400. // Global helpers so CEditFrame and CComposeFrame (mail message) can share 
  401. //   dynamic menu functionality
  402. BOOL edt_GetMessageString(CView *pView, UINT MenuId, CString& Message);
  403. BOOL edt_IsEditorDynamicMenu(WPARAM wParam);
  404. #endif
  405.  
  406. CGenericFrame *wfe_FrameFromXPContext(MWContext * pXPCX);
  407.  
  408. static UINT NEAR WM_FINDREPLACE = ::RegisterWindowMessage(FINDMSGSTRING);
  409. static UINT NEAR WM_HELPMSG = ::RegisterWindowMessage(HELPMSGSTRING);
  410. #endif
  411.