Back to index

lightning-sunbird  0.9+nobinonly
CBrowserShell.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
00002  *
00003  * ***** BEGIN LICENSE BLOCK *****
00004  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00005  *
00006  * The contents of this file are subject to the Mozilla Public License Version
00007  * 1.1 (the "License"); you may not use this file except in compliance with
00008  * the License. You may obtain a copy of the License at
00009  * http://www.mozilla.org/MPL/
00010  *
00011  * Software distributed under the License is distributed on an "AS IS" basis,
00012  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00013  * for the specific language governing rights and limitations under the
00014  * License.
00015  *
00016  * The Original Code is the Mozilla browser.
00017  *
00018  * The Initial Developer of the Original Code is
00019  * Netscape Communications, Inc.
00020  * Portions created by the Initial Developer are Copyright (C) 1999
00021  * the Initial Developer. All Rights Reserved.
00022  *
00023  * Contributor(s):
00024  *   Conrad Carlen <ccarlen@netscape.com>
00025  *
00026  * Alternatively, the contents of this file may be used under the terms of
00027  * either the GNU General Public License Version 2 or later (the "GPL"), or
00028  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00029  * in which case the provisions of the GPL or the LGPL are applicable instead
00030  * of those above. If you wish to allow use of your version of this file only
00031  * under the terms of either the GPL or the LGPL, and not to allow others to
00032  * use your version of this file under the terms of the MPL, indicate your
00033  * decision by deleting the provisions above and replace them with the notice
00034  * and other provisions required by the GPL or the LGPL. If you do not delete
00035  * the provisions above, a recipient may use your version of this file under
00036  * the terms of any one of the MPL, the GPL or the LGPL.
00037  *
00038  * ***** END LICENSE BLOCK ***** */
00039 
00040 #ifndef __CBrowserShell__
00041 #define __CBrowserShell__
00042 
00043 #include <LView.h>
00044 #include <LCommander.h>
00045 #include <LPeriodical.h>
00046 #include <LListener.h>
00047 #include <LString.h>
00048 #include <LDragAndDrop.h>
00049 
00050 #include "CHeaderSniffer.h"
00051 
00052 #include "nsCOMPtr.h"
00053 #include "nsAString.h"
00054 #include "nsIWebBrowser.h"
00055 #include "nsIBaseWindow.h"
00056 #include "nsIWebNavigation.h"
00057 #include "nsIEventSink.h"
00058 #include "nsIWebProgress.h"
00059 #include "nsIDragHelperService.h"
00060 #include "nsIPrintSettings.h"
00061 
00062 class CBrowserChrome;
00063 class CBrowserShellProgressListener;
00064 
00065 class nsIContentViewer;
00066 class nsIClipboardCommands;
00067 class nsIDOMEvent;
00068 class nsIDOMNode;
00069 class nsIContextMenuInfo;
00070 
00071 //*****************************************************************************
00072 //***    CBrowserShell
00073 //*****************************************************************************
00074 
00075 class CBrowserShell : public LView,
00076                       public LCommander,
00077                       public LBroadcaster,
00078                       public LPeriodical,
00079                       public LDropArea
00080 {
00081     friend class CBrowserChrome;
00082       
00083 private:
00084     typedef LView Inherited;
00085 
00086 public:
00087     enum { class_ID = FOUR_CHAR_CODE('BroS') };
00088     enum { paneID_MainBrowser = 'WebS' };
00089     static const nsCString      kEmptyCString;
00090 
00091                                 CBrowserShell();
00092                                 CBrowserShell(const SPaneInfo   &inPaneInfo,
00093                                               const SViewInfo   &inViewInfo,
00094                                               UInt32            inChromeFlags,
00095                                               Boolean           inIsMainContent);
00096                                 CBrowserShell(LStream*  inStream);
00097 
00098     virtual                     ~CBrowserShell();
00099     
00100 
00101     // LPane
00102     virtual void                FinishCreateSelf();
00103     virtual void                ResizeFrameBy(SInt16        inWidthDelta,
00104                                               SInt16        inHeightDelta,
00105                                               Boolean       inRefresh);
00106     virtual void                MoveBy(SInt32   inHorizDelta,
00107                                        SInt32   inVertDelta,
00108                                        Boolean  inRefresh);
00109                                        
00110     virtual void                ActivateSelf();
00111     virtual void                DeactivateSelf();
00112     virtual void                ShowSelf();
00113     virtual void                DrawSelf(); 
00114     virtual void                ClickSelf(const SMouseDownEvent &inMouseDown);
00115     virtual void                EventMouseUp(const EventRecord  &inMacEvent);
00116     
00117     virtual void                AdjustMouseSelf(Point               /* inPortPt */,
00118                                                 const EventRecord&  inMacEvent,
00119                                                 RgnHandle           outMouseRgn);
00120 
00121     // LCommander
00122     virtual void                BeTarget();
00123     virtual void                DontBeTarget();
00124     virtual Boolean             HandleKeyPress(const EventRecord    &inKeyEvent);
00125     virtual Boolean             ObeyCommand(PP_PowerPlant::CommandT inCommand, void* ioParam);
00126     virtual void                FindCommandStatus(PP_PowerPlant::CommandT inCommand,
00127                                                   Boolean &outEnabled, Boolean &outUsesMark,
00128                                                   UInt16 &outMark, Str255 outName);
00129 
00130     // LPeriodical
00131     virtual void                SpendTime(const EventRecord&        inMacEvent);
00132     
00133         // Text Input Event Handling
00134     virtual OSStatus HandleUpdateActiveInputArea(const nsAString& text, 
00135                                                  PRInt16 script,  PRInt16 language, 
00136                                                  PRInt32 fixLen, const TextRangeArray * hiliteRng);
00137     virtual OSStatus HandleUnicodeForKeyEvent(const nsAString& text, 
00138                                               PRInt16 script, PRInt16 language, 
00139                                               const EventRecord* keyboardEvent);
00140     virtual OSStatus HandleOffsetToPos(PRInt32 offset, PRInt16 *pointX, PRInt16 *pointY);
00141     virtual OSStatus HandlePosToOffset(PRInt16 currentPointX, PRInt16 currentPointY, 
00142                                        PRInt32 *offset, PRInt16 *regionClass);
00143     virtual OSStatus HandleGetSelectedText(nsAString& selectedText);
00144     
00145     
00146     // CBrowserShell
00147         
00148         // Called by the window creator after parameterized contructor. Not used
00149         // when we're created from a 'PPob' resource. In that case, attachments can be
00150         // added with Constructor.
00151     virtual void            AddAttachments();
00152     
00153     NS_METHOD               GetWebBrowser(nsIWebBrowser** aBrowser);
00154     NS_METHOD               SetWebBrowser(nsIWebBrowser* aBrowser);
00155                             // Drops ref to current one, installs given one
00156                             
00157     NS_METHOD               GetWebBrowserChrome(nsIWebBrowserChrome** aChrome);
00158                             
00159     NS_METHOD               GetContentViewer(nsIContentViewer** aViewer);
00160     
00161     NS_METHOD               GetPrintSettings(nsIPrintSettings** aSettings);
00162 
00163     NS_METHOD               GetFocusedWindowURL(nsAString& outURL);
00164     
00165     Boolean                 IsBusy();
00166     Boolean                 CanGoBack();
00167     Boolean                 CanGoForward();
00168 
00169     NS_METHOD               Back();
00170     NS_METHOD               Forward();
00171     NS_METHOD               Stop();
00172     NS_METHOD               Reload();
00173     
00174         // String params are UTF-8 encoded.                        
00175     NS_METHOD               LoadURL(const nsACString& urlText, const nsACString& referrer = kEmptyCString);
00176     NS_METHOD               GetCurrentURL(nsACString& urlText);
00177 
00178         // Puts up a Save As dialog and saves current URI and all images, etc.
00179     NS_METHOD               SaveDocument(ESaveFormat inSaveFormat = eSaveFormatUnspecified);
00180         // Puts up a Save As dialog and saves the given URI. Pass null to save the current page.
00181     NS_METHOD               SaveLink(nsIURI* inURI);
00182     NS_METHOD               SaveInternal(nsIURI* inURI, nsIDOMDocument* inDocument, const nsAString& inSuggestedFilename, Boolean inBypassCache, ESaveFormat inSaveFormat = eSaveFormatUnspecified);
00183     
00184        // Puts up a find dialog and does the find operation                        
00185     Boolean                 Find();
00186        // Does the find operation with the given params - no UI
00187     Boolean                 Find(const nsAString& searchStr,
00188                                 Boolean caseSensitive,
00189                                 Boolean searchBackward,
00190                                 Boolean wrapSearch,
00191                                 Boolean wholeWordOnly);
00192     Boolean                 CanFindNext();
00193     Boolean                 FindNext();
00194                             
00195 protected:
00196 
00197     // LDropArea
00198     virtual void            InsideDropArea( DragReference inDragRef );
00199     virtual Boolean         PointInDropArea( Point inGlobalPt) ;
00200     virtual Boolean         DragIsAcceptable( DragReference inDragRef );
00201     virtual void            EnterDropArea( DragReference inDragRef, Boolean inDragHasLeftSender);
00202     virtual void            LeaveDropArea( DragReference inDragRef );
00203     virtual void            DoDragReceive( DragReference inDragRef );
00204 
00205     NS_IMETHOD              OnShowContextMenu(PRUint32 aContextFlags,
00206                                               nsIContextMenuInfo *aInfo);
00207                                               
00208     NS_IMETHOD              OnShowTooltip(PRInt32 aXCoords,
00209                                           PRInt32 aYCoords,
00210                                           const PRUnichar *aTipText);
00211     NS_IMETHOD              OnHideTooltip();
00212                                               
00213                                               
00214    NS_METHOD                CommonConstruct();
00215    
00216    void                     HandleMouseMoved(const EventRecord& inMacEvent);
00217    void                     AdjustFrame();
00218    virtual Boolean          DoFindDialog(nsAString& searchText,
00219                                          PRBool& findBackwards,
00220                                          PRBool& wrapFind,
00221                                          PRBool& entireWord,
00222                                          PRBool& caseSensitive);
00223 
00224    NS_METHOD                GetClipboardHandler(nsIClipboardCommands **aCommand);
00225    
00226    Boolean                  HasFormElements();
00227 
00228    virtual void             PostOpenURLEvent(const nsACString& url, const nsACString& referrer);
00229     
00230 protected:   
00231     UInt32                          mChromeFlags;
00232     Boolean                         mIsMainContent;
00233       
00234     nsCOMPtr<nsIEventSink>          mEventSink;             // for event dispatch
00235     nsCOMPtr<nsIWebBrowser>         mWebBrowser;            // The thing we actually create
00236     nsCOMPtr<nsIBaseWindow>         mWebBrowserAsBaseWin;   // Convenience interface to above 
00237     nsCOMPtr<nsIWebNavigation>      mWebBrowserAsWebNav;    // Ditto
00238    
00239     static nsCOMPtr<nsIDragHelperService> sDragHelper;
00240 
00241     CBrowserChrome                  *mChrome;
00242     CBrowserShellProgressListener   *mProgressListener;
00243     
00244         // These are stored only during OnShowContextMenu so that they can
00245         // be used by FindCommandStatus and ObeyCommand which get called
00246         // during OnShowContextMenu.
00247     PRUint32                        mContextMenuFlags;
00248     nsIContextMenuInfo             *mContextMenuInfo;
00249     
00250     nsCOMPtr<nsIPrintSettings>      mPrintSettings;
00251 };
00252 
00253 
00254 #endif // __CBrowserShell__