Back to index

lightning-sunbird  0.9+nobinonly
BrowserFrm.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: MPL 1.1/GPL 2.0/LGPL 2.1
00004  *
00005  * The contents of this file are subject to the Mozilla Public License Version
00006  * 1.1 (the "License"); you may not use this file except in compliance with
00007  * the License. You may obtain a copy of the License at
00008  * http://www.mozilla.org/MPL/
00009  *
00010  * Software distributed under the License is distributed on an "AS IS" basis,
00011  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00012  * for the specific language governing rights and limitations under the
00013  * License.
00014  *
00015  * The Original Code is mozilla.org code.
00016  *
00017  * The Initial Developer of the Original Code is
00018  * Netscape Communications Corporation.
00019  * Portions created by the Initial Developer are Copyright (C) 1998
00020  * the Initial Developer. All Rights Reserved.
00021  *
00022  * Contributor(s):
00023  *   Chak Nanga <chak@netscape.com>
00024  *
00025  * Alternatively, the contents of this file may be used under the terms of
00026  * either the GNU General Public License Version 2 or later (the "GPL"), or
00027  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00028  * in which case the provisions of the GPL or the LGPL are applicable instead
00029  * of those above. If you wish to allow use of your version of this file only
00030  * under the terms of either the GPL or the LGPL, and not to allow others to
00031  * use your version of this file under the terms of the MPL, indicate your
00032  * decision by deleting the provisions above and replace them with the notice
00033  * and other provisions required by the GPL or the LGPL. If you do not delete
00034  * the provisions above, a recipient may use your version of this file under
00035  * the terms of any one of the MPL, the GPL or the LGPL.
00036  *
00037  * ***** END LICENSE BLOCK ***** */
00038 
00039 // BrowserFrm.h : interface of the CBrowserFrame class
00040 //
00042 
00043 #ifndef _IBROWSERFRM_H
00044 #define _IBROWSERFRM_H
00045 
00046 #if _MSC_VER > 1000
00047 #pragma once
00048 #endif // _MSC_VER > 1000
00049 
00050 #include "BrowserView.h"
00051 #include "BrowserToolTip.h"
00052 #include "IBrowserFrameGlue.h"
00053 #include "MostRecentUrls.h"
00054 
00055 // A simple UrlBar class...
00056 class CUrlBar : public CComboBoxEx
00057 {
00058 public:
00059        inline void GetEnteredURL(CString& url) {
00060               GetEditCtrl()->GetWindowText(url);
00061        }
00062        inline void GetSelectedURL(CString& url) {
00063               GetLBText(GetCurSel(), url);
00064        }
00065        inline void SetCurrentURL(LPCTSTR pUrl) {
00066               SetWindowText(pUrl);
00067        }
00068        inline void AddURLToList(CString& url, bool bAddToMRUList = true) {
00069               COMBOBOXEXITEM ci;
00070               ci.mask = CBEIF_TEXT; ci.iItem = -1;
00071               ci.pszText = (LPTSTR)(LPCTSTR)url;
00072               InsertItem(&ci);
00073 
00074         if(bAddToMRUList)
00075             m_MRUList.AddURL((LPTSTR)(LPCTSTR)url);
00076        }
00077     inline void LoadMRUList() {
00078         for (int i=0;i<m_MRUList.GetNumURLs();i++) 
00079         {
00080             CString urlStr(_T(m_MRUList.GetURL(i)));
00081             AddURLToList(urlStr, false); 
00082         }
00083     }
00084     inline BOOL EditCtrlHasFocus() {
00085         return (GetEditCtrl()->m_hWnd == CWnd::GetFocus()->m_hWnd);
00086     }
00087     inline BOOL EditCtrlHasSelection() {
00088         int nStartChar = 0, nEndChar = 0;
00089         if(EditCtrlHasFocus())
00090             GetEditCtrl()->GetSel(nStartChar, nEndChar);
00091         return (nEndChar > nStartChar) ? TRUE : FALSE;
00092     }
00093     inline BOOL CanCutToClipboard() {
00094         return EditCtrlHasSelection();
00095     }
00096     inline void CutToClipboard() {
00097         GetEditCtrl()->Cut();
00098     }
00099     inline BOOL CanCopyToClipboard() {
00100         return EditCtrlHasSelection();
00101     }
00102     inline void CopyToClipboard() {
00103         GetEditCtrl()->Copy();
00104     }
00105     inline BOOL CanPasteFromClipboard() {
00106         return EditCtrlHasFocus();
00107     }
00108     inline void PasteFromClipboard() {
00109         GetEditCtrl()->Paste();
00110     }
00111     inline BOOL CanUndoEditOp() {
00112         return EditCtrlHasFocus() ? GetEditCtrl()->CanUndo() : FALSE;
00113     }
00114     inline void UndoEditOp() {        
00115         if(EditCtrlHasFocus())
00116             GetEditCtrl()->Undo();
00117     }
00118 
00119 protected:
00120       CMostRecentUrls m_MRUList;
00121 };
00122 
00123 class CBrowserFrame : public CFrameWnd
00124 {      
00125 public:
00126        CBrowserFrame(PRUint32 chromeMask);
00127 
00128 protected: 
00129        DECLARE_DYNAMIC(CBrowserFrame)
00130 
00131 public:
00132        inline CBrowserImpl *GetBrowserImpl() { return m_wndBrowserView.mpBrowserImpl; }
00133 
00134        CToolBar    m_wndToolBar;
00135        CStatusBar  m_wndStatusBar;
00136        CProgressCtrl m_wndProgressBar;
00137        CUrlBar m_wndUrlBar;
00138        CReBar m_wndReBar;
00139        // The view inside which the embedded browser will
00140        // be displayed in
00141        CBrowserToolTip m_wndTooltip;
00142        CBrowserView    m_wndBrowserView;
00143 
00144     // Wrapper functions for UrlBar clipboard operations
00145     inline BOOL CanCutUrlBarSelection() { return m_wndUrlBar.CanCutToClipboard(); }
00146     inline void CutUrlBarSelToClipboard() { m_wndUrlBar.CutToClipboard(); }
00147     inline BOOL CanCopyUrlBarSelection() { return m_wndUrlBar.CanCopyToClipboard(); }
00148     inline void CopyUrlBarSelToClipboard() { m_wndUrlBar.CopyToClipboard(); }
00149     inline BOOL CanPasteToUrlBar() { return m_wndUrlBar.CanPasteFromClipboard(); }
00150     inline void PasteFromClipboardToUrlBar() { m_wndUrlBar.PasteFromClipboard(); }
00151     inline BOOL CanUndoUrlBarEditOp() { return m_wndUrlBar.CanUndoEditOp(); }
00152     inline void UndoUrlBarEditOp() { m_wndUrlBar.UndoEditOp(); }
00153 
00154        // This specifies what UI elements this frame will sport
00155        // w.r.t. toolbar, statusbar, urlbar etc.
00156        PRUint32 m_chromeMask;
00157 
00158 protected:
00159        //
00160        // This nested class implements the IBrowserFramGlue interface
00161        // The Gecko embedding interfaces call on this interface
00162        // to update the status bars etc.
00163        //
00164        class BrowserFrameGlueObj : public IBrowserFrameGlue 
00165        {
00166               //
00167               // NS_DECL_BROWSERFRAMEGLUE below is a macro which expands
00168               // to the function prototypes of methods in IBrowserFrameGlue
00169               // Take a look at IBrowserFrameGlue.h for this macro define
00170               //
00171 
00172               NS_DECL_BROWSERFRAMEGLUE
00173 
00174        } m_xBrowserFrameGlueObj;
00175        friend class BrowserFrameGlueObj;
00176 
00177 public:
00178        void SetupFrameChrome();
00179 
00180 // Overrides
00181        // ClassWizard generated virtual function overrides
00182        //{{AFX_VIRTUAL(CBrowserFrame)
00183        virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
00184        virtual BOOL OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo);
00185        //}}AFX_VIRTUAL
00186 
00187 // Implementation
00188 public:
00189        virtual ~CBrowserFrame();
00190 #ifdef _DEBUG
00191        virtual void AssertValid() const;
00192        virtual void Dump(CDumpContext& dc) const;
00193 #endif
00194 
00195 // Generated message map functions
00196 protected:
00197        //{{AFX_MSG(CBrowserFrame)
00198        afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
00199        afx_msg void OnSetFocus(CWnd *pOldWnd);
00200        afx_msg void OnSize(UINT nType, int cx, int cy);
00201        afx_msg void OnClose();
00202        afx_msg void OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized);
00203        //}}AFX_MSG
00204        DECLARE_MESSAGE_MAP()
00205 };
00206 
00208 
00209 //{{AFX_INSERT_LOCATION}}
00210 // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
00211 
00212 #endif //_IBROWSERFRM_H