home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / cmd / winfe / edframe.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  7.0 KB  |  191 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. #ifdef EDITOR
  20.  
  21. #ifndef EDFRAME_H
  22. #define EDFRAME_H
  23.  
  24. #include "mainfrm.h"
  25. #include "edcombtb.h"
  26. #include "pa_tags.h"   // Needed for P_... container tag defines
  27. #include "edprops.h"
  28. #include "edtrccln.h"
  29.  
  30. // Matches size of custom colors in Windows color picker
  31. #define    MAX_FONT_COLOR    16
  32.  
  33. // Global for app - called during startup
  34. BOOL FE_FindPreviousInstance(LPCSTR szURL, BOOL bStartEditor);
  35.  
  36. // Checks if there is any active editor plugin and lets the user stop it.
  37. // Return: TRUE - no plugin was running or user stopped the active plugin
  38. //         FALSE - user didn't want to stop the plugin
  39. BOOL CheckAndCloseEditorPlugin(MWContext *pMWContext);
  40.  
  41. void WFE_InitComposer();
  42.  
  43. ///////////////////////////////////////////////////////////////////////////////////////////////
  44. // Class to own the Composer toolbar so it can be used by both Web and Mail Composer frames
  45.  
  46. #define WM_TOOLCONTROLLER WM_USER+512
  47. #define DISPLAY_EDIT_TOOLBAR        0x1
  48. #define DISPLAY_FORMAT_TOOLBAR        0x2  // NOT USED
  49. #define DISPLAY_CHARACTER_TOOLBAR    0x4
  50. #define DISPLAY_FORMS_TOOLBAR        0x8
  51. #define INDEX_OTHER                 -2
  52.  
  53. class CEditToolBarController {
  54. public:
  55.     CEditToolBarController(CWnd * pParent = NULL);    
  56.     ~CEditToolBarController();
  57.  
  58. private:
  59.     CComboToolBar    m_wndCharacterBar;
  60.     CCommandToolbar* m_pCharacterToolbar;
  61.     // Custom toolbar allows Comboboxes, but we own them
  62.     CComboBox        m_ParagraphCombo;
  63.     CColorComboBox   m_FontColorCombo;
  64.     CNSComboBox      m_FontFaceCombo;
  65.     CNSComboBox      m_FontSizeCombo;
  66.     CWnd *             m_pWnd;
  67.     // Save the index in listbox for "Other..." item used to trigger dialogs
  68.     int              m_iFontColorOtherIndex;
  69.  
  70. public:
  71.     void ShowToolBar( BOOL bShow, CComboToolBar * pToolBar = NULL);
  72.  
  73.     inline CWnd * GetParent() { return m_pWnd; } 
  74.  
  75.     inline CComboBox* GetParagraphCombo() { return &m_ParagraphCombo; }
  76.     inline CColorComboBox* GetFontColorCombo() { return &m_FontColorCombo; }
  77.     inline CNSComboBox* GetFontFaceCombo() { return &m_FontFaceCombo; }
  78.     inline CNSComboBox* GetFontSizeCombo() { return &m_FontSizeCombo; }
  79.     inline CComboToolBar* GetCharacterBar() { return( ::IsWindow(m_wndCharacterBar.m_hWnd) ? &m_wndCharacterBar : 0); }
  80.     inline CCommandToolbar *GetCNSToolbar() { return( ::IsWindow(m_pCharacterToolbar->m_hWnd) ? m_pCharacterToolbar : 0); }
  81.     // Pass in MWContext to get palette to be used by comboboxes and display status messages
  82.     BOOL CreateEditBars(MWContext *pMWContext,
  83.                         unsigned ett = DISPLAY_EDIT_TOOLBAR|DISPLAY_CHARACTER_TOOLBAR);
  84.     
  85.     // Calls appropriate GetCurSel(), but returns INDEX_OTHER if "Other..." item selected
  86.     int GetSelectedFontFaceIndex();
  87.     int GetSelectedFontColorIndex();
  88.     
  89. protected:
  90.     CCommandToolbar* CreateCharacterToolbar(int nCount);
  91.  
  92. };
  93.  
  94. /////////////////////////////////////////////////////////////////////////////////
  95. // This is Editors wrapper around main frame so we can handle our own UI
  96. //  and keep out of the way of Browser crew
  97.  
  98. class CEditFrame : public CMainFrame
  99. {
  100. public: // create from serialization only
  101.     CEditFrame();
  102.     DECLARE_DYNCREATE(CEditFrame)
  103.  
  104.     CEditToolBarController * m_pToolBarController;
  105.  
  106.     // Overriden for setting the command help for editor plugin tools and edit history list
  107.     virtual void GetMessageString(UINT MenuID, CString& Message) const;
  108.  
  109. // Attributes
  110. public:
  111.     // Store context associated with URL that
  112.     //   we want to convert to a new doc
  113.     // Signals appropriate action in FE_EditorGetUrlExitRoutine()
  114.     MWContext      * m_pTemplateContext;
  115.     // Set this to trigger importing a text file just like
  116.     //  we handle a template file - change it to an Untitled new doc
  117.     //  to prevent overwriting original file    
  118.     BOOL             m_bImportTextFile;
  119.  
  120. private:
  121.     // Save original state of browser toolbars
  122.     BOOL             m_bSaveShowURLBar;
  123.     BOOL             m_bSaveShowBrowseBar;
  124.     BOOL             m_bSaveShowStarterBar;
  125.  
  126. // Implementation
  127. public:
  128.     virtual         ~CEditFrame();
  129.     virtual BOOL    OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext *pContext);
  130.  
  131.     void SetNavToolbarButtonCommandID( BOOL bOpenNewWindow );
  132.  
  133.     // Don't allow NavCenter windows to be placed in edit windows.
  134.     inline BOOL AllowDocking() { return FALSE; }
  135.     
  136.     inline CComboBox* GetParagraphCombo() { return m_pToolBarController->GetParagraphCombo(); }
  137.     inline CColorComboBox* GetFontColorCombo() { return m_pToolBarController->GetFontColorCombo(); }
  138.     inline CComboBox* GetFontSizeCombo() { return m_pToolBarController->GetFontSizeCombo(); }
  139.     inline CComboToolBar* GetCharacterBar() { return m_pToolBarController->GetCharacterBar(); }
  140.  
  141.     BOOL IsEditFrame() { return TRUE; }
  142.  
  143.     // Save given URL to list in template preferences.
  144.     // If NULL, get location from "editor.template_last_loc"
  145.     void SaveTemplateLocation(char *pLastLoc = NULL);
  146.  
  147. #ifdef _DEBUG
  148.     virtual void AssertValid() const;
  149.     virtual void Dump(CDumpContext& dc) const;
  150. #endif
  151.  
  152. protected:  
  153.     void DockControlBarLeftOf(CToolBar* Bar,CToolBar* LeftOf);
  154.     //void BuildRecentFilesMenu(CMenu * pMenu);
  155.  
  156.     // Prompts user to supply required URL if missing from preferences.
  157.     // Allows selecting a local file
  158.     // nID_Caption is string ID for dialog,
  159.     // nID_Msg used for prompt above edit field
  160.     // nID_FileCaption is used for OpenFile dialog caption
  161.     char *GetLocationFromPreferences(const char *pPrefName, UINT nID_Msg = 0, UINT nID_Caption = 0,  UINT nID_FileCaption = 0);
  162.  
  163.     HPALETTE m_hPal;
  164.  
  165. // Generated message map functions
  166. protected:
  167.     //{{AFX_MSG(CEditFrame)
  168.     afx_msg LONG OnToolController(UINT,LONG);
  169.     afx_msg int  OnCreate(LPCREATESTRUCT lpCreateStruct);
  170.     afx_msg void OnClose();
  171.     afx_msg void OnFileClose();
  172.     afx_msg void OnNewFrame();
  173.     afx_msg BOOL OnQueryEndSession();
  174.     afx_msg void OnEditFindReplace();
  175.     afx_msg void OnShowBookmarkWindow();
  176. //}}AFX_MSG
  177.     afx_msg LRESULT OnSetMessageString(WPARAM wParam, LPARAM lParam);
  178.     LRESULT OnButtonMenuOpen(WPARAM wParam, LPARAM lParam);
  179.  
  180.     // Callback from editor.
  181.     void RealClose();
  182.     static void RealCloseS(void* hook);
  183.  
  184.     DECLARE_MESSAGE_MAP()
  185.  
  186.     friend class CPrefEditorPage;    
  187.     friend class CNetscapeEditView;
  188. };
  189. #endif // EDFRAME_H
  190. #endif // EDITOR
  191.