Back to index

lightning-sunbird  0.9+nobinonly
EditorFrm.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
00002 /* ***** BEGIN LICENSE BLOCK *****
00003  * Version: Mozilla-sample-code 1.0
00004  *
00005  * Copyright (c) 2002 Netscape Communications Corporation and
00006  * other contributors
00007  *
00008  * Permission is hereby granted, free of charge, to any person obtaining a
00009  * copy of this Mozilla sample software and associated documentation files
00010  * (the "Software"), to deal in the Software without restriction, including
00011  * without limitation the rights to use, copy, modify, merge, publish,
00012  * distribute, sublicense, and/or sell copies of the Software, and to permit
00013  * persons to whom the Software is furnished to do so, subject to the
00014  * following conditions:
00015  *
00016  * The above copyright notice and this permission notice shall be included
00017  * in all copies or substantial portions of the Software.
00018  *
00019  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
00020  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00021  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
00022  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
00023  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
00024  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
00025  * DEALINGS IN THE SOFTWARE.
00026  *
00027  * Contributor(s):
00028  *   Mike Judge <mjudge@netscape.com>
00029  *   Chak Nanga <chak@netscape.com>
00030  *
00031  * ***** END LICENSE BLOCK ***** */
00032 
00033 #ifndef _EDITORFRM_H_
00034 #define _EDITORFRM_H_
00035 
00036 class nsICommandParams;
00037 class nsIEditor;
00038 class nsIHTMLEditor;
00039 
00040 #include "nsIEditingSession.h"
00041 #include "nsICommandManager.h"
00042 
00043 class CEditorFrame : public CBrowserFrame
00044 {    
00045 public:
00046     CEditorFrame(PRUint32 chromeMask);
00047     virtual ~CEditorFrame();
00048 
00049 protected: 
00050     DECLARE_DYNAMIC(CEditorFrame)
00051 
00052 public:
00053     BOOL InitEditor();
00054     NS_METHOD MakeEditable();
00055     NS_METHOD DoCommand(const char *aCommand, nsICommandParams *aCommandParams);
00056     NS_METHOD IsCommandEnabled(const char *aCommand, PRBool *retval);
00057     NS_METHOD GetCommandState(const char *aCommand, nsICommandParams *aCommandParams);
00058 
00059     void GetEditor(nsIEditor** editor);
00060     void GetHTMLEditor(nsIHTMLEditor** htmlEditor);
00061     BOOL InLink();
00062     void ShowInsertLinkDlg();
00063     void ShowEditLinkDlg();
00064     BOOL GetCurrentLinkInfo(CString& strLinkText, CString& strLinkLocation, nsIDOMHTMLAnchorElement** anchorElement);
00065     void InsertLink(CString& linkText, CString& linkLocation);
00066     void InsertHTML(CString& str);
00067 
00068 // Generated message map functions
00069 protected:
00070     //{{AFX_MSG(CEditorFrame)
00071     afx_msg void OnBold();
00072     afx_msg void OnUpdateBold(CCmdUI* pCmdUI);
00073     afx_msg void OnItalics();
00074     afx_msg void OnUpdateItalics(CCmdUI* pCmdUI);
00075     afx_msg void OnUnderline();
00076     afx_msg void OnUpdateUnderline(CCmdUI* pCmdUI);
00077     afx_msg void OnIndent();
00078     afx_msg void OnUpdateIndent(CCmdUI* pCmdUI);
00079     afx_msg void OnOutdent();
00080     afx_msg void OnUpdateOutdent(CCmdUI* pCmdUI);
00081     afx_msg void OnFontred();
00082     afx_msg void OnUpdateFontred(CCmdUI* pCmdUI);
00083     afx_msg void OnFontblack();
00084     afx_msg void OnUpdateFontblack(CCmdUI* pCmdUI);
00085     afx_msg void OnBgcolor();
00086     afx_msg void OnUpdateBgcolor(CCmdUI* pCmdUI);
00087     afx_msg void OnNobgcolor();
00088     afx_msg void OnUpdateNobgcolor(CCmdUI* pCmdUI);
00089     afx_msg void OnFontsizeincrease();
00090     afx_msg void OnFontsizedecrease();
00091     afx_msg void OnArial();
00092     afx_msg void OnTimes();
00093     afx_msg void OnCourier();
00094     afx_msg void OnAlignleft();
00095     afx_msg void OnUpdateAlignleft(CCmdUI* pCmdUI);
00096     afx_msg void OnAlignright();
00097     afx_msg void OnUpdateAlignright(CCmdUI* pCmdUI);
00098     afx_msg void OnAligncenter();
00099     afx_msg void OnUpdateAligncenter(CCmdUI* pCmdUI);
00100     afx_msg void OnInsertlink();
00101     afx_msg void OnEditUndo();
00102     afx_msg void OnEditRedo();
00103     afx_msg void OnUpdateEditRedo(CCmdUI* pCmdUI);
00104     afx_msg void OnUpdateEditUndo(CCmdUI* pCmdUI);
00105     //}}AFX_MSG
00106 
00107     DECLARE_MESSAGE_MAP()
00108 
00109 private:
00110     NS_METHOD ExecuteStyleCommand(const char *aCommand);
00111     NS_METHOD ExecuteNoParam(const char *aCommand);
00112     NS_METHOD MakeCommandParams(const char *aCommand,nsICommandParams **aParams);
00113     NS_METHOD ExecuteAttribParam(const char *aCommand, const char *aAttribute);
00114     NS_METHOD GetAttributeParamValue(const char *aCommand, nsEmbedCString &aValue);
00115 
00116     void UpdateStyleToolBarBtn(const char *aCommand, CCmdUI* pCmdUI);
00117 
00118 private:
00119     nsCOMPtr<nsICommandManager> mCommandManager;
00120     nsCOMPtr<nsIDOMWindow> mDOMWindow;
00121        nsCOMPtr<nsIEditingSession> mEditingSession;
00122 };
00123 
00124 #endif //_EDITORFRM_H_