Back to index

lightning-sunbird  0.9+nobinonly
CHBrowserView.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
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  *
00024  * Alternatively, the contents of this file may be used under the terms of
00025  * either the GNU General Public License Version 2 or later (the "GPL"), or
00026  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00027  * in which case the provisions of the GPL or the LGPL are applicable instead
00028  * of those above. If you wish to allow use of your version of this file only
00029  * under the terms of either the GPL or the LGPL, and not to allow others to
00030  * use your version of this file under the terms of the MPL, indicate your
00031  * decision by deleting the provisions above and replace them with the notice
00032  * and other provisions required by the GPL or the LGPL. If you do not delete
00033  * the provisions above, a recipient may use your version of this file under
00034  * the terms of any one of the MPL, the GPL or the LGPL.
00035  *
00036  * ***** END LICENSE BLOCK ***** */
00037 
00038 #ifndef __nsCocoaBrowserView_h__
00039 #define __nsCocoaBrowserView_h__
00040 
00041 #undef DARWIN
00042 #import <Cocoa/Cocoa.h>
00043 
00044 @class CHBrowserView;
00045 class CHBrowserListener;
00046 class nsIDOMWindow;
00047 class nsIWebBrowser;
00048 class nsIDOMNode;
00049 class nsIDOMEvent;
00050 class nsIWebBrowserFind;
00051 class nsIEventSink;
00052 class nsIDragHelperService;
00053 
00054 
00055 // Protocol implemented by anyone interested in progress
00056 // related to a BrowserView. A listener should explicitly
00057 // register itself with the view using the addListener
00058 // method.
00059 @protocol CHBrowserListener
00060 
00061 - (void)onLoadingStarted;
00062 - (void)onLoadingCompleted:(BOOL)succeeded;
00063 // Invoked regularly as data associated with a page streams
00064 // in. If the total number of bytes expected is unknown,
00065 // maxBytes is -1.
00066 - (void)onProgressChange:(int)currentBytes outOf:(int)maxBytes;
00067 - (void)onLocationChange:(NSString*)urlSpec;
00068 - (void)onStatusChange:(NSString*)aMessage;
00069 - (void)onSecurityStateChange:(unsigned long)newState;
00070 // Called when a context menu should be shown.
00071 - (void)onShowContextMenu:(int)flags domEvent:(nsIDOMEvent*)aEvent domNode:(nsIDOMNode*)aNode;
00072 // Called when a tooltip should be shown or hidden
00073 - (void)onShowTooltip:(NSPoint)where withText:(NSString*)text;
00074 - (void)onHideTooltip;
00075 
00076 @end
00077 
00078 typedef enum {
00079   NSStatusTypeScript            = 0x0001,
00080   NSStatusTypeScriptDefault     = 0x0002,
00081   NSStatusTypeLink              = 0x0003,
00082 } NSStatusType;
00083 
00084 @protocol CHBrowserContainer
00085 
00086 - (void)setStatus:(NSString *)statusString ofType:(NSStatusType)type;
00087 - (NSString *)title;
00088 - (void)setTitle:(NSString *)title;
00089 // Set the dimensions of our NSView. The container might need to do
00090 // some adjustment, so the view doesn't do it directly.
00091 - (void)sizeBrowserTo:(NSSize)dimensions;
00092 // Create a new browser container window and return the contained view. 
00093 - (CHBrowserView*)createBrowserWindow:(unsigned int)mask;
00094 
00095 - (NSMenu*)getContextMenu;
00096 - (NSWindow*)getNativeWindow;
00097 
00098 // Ask whether the browser should accept a drag from the given source.
00099 // Should return NO if the source is a container for the browser, or
00100 // another item that represents the same entity (e.g. tab or proxy icon)
00101 - (BOOL)shouldAcceptDragFromSource:(id)dragSource;
00102 
00103 @end
00104 
00105 enum {
00106   NSLoadFlagsNone                   = 0x0000,
00107   NSLoadFlagsDontPutInHistory       = 0x0010,
00108   NSLoadFlagsReplaceHistoryEntry    = 0x0020,
00109   NSLoadFlagsBypassCacheAndProxy    = 0x0040
00110 }; 
00111 
00112 enum {
00113   NSStopLoadNetwork   = 0x01,
00114   NSStopLoadContent   = 0x02,
00115   NSStopLoadAll       = 0x03  
00116 };
00117 
00118 @interface CHBrowserView : NSView 
00119 {
00120   nsIWebBrowser* _webBrowser;
00121   CHBrowserListener* _listener;
00122   NSWindow* mWindow;
00123   
00124   nsIDragHelperService* mDragHelper;
00125   NSPoint               mLastTrackedLocation;
00126   NSWindow*             mLastTrackedWindow;
00127 }
00128 
00129 // NSView overrides
00130 - (id)initWithFrame:(NSRect)frame;
00131 - (id)initWithFrame:(NSRect)frame andWindow:(NSWindow*)aWindow;
00132 
00133 - (void)dealloc;
00134 - (void)setFrame:(NSRect)frameRect;
00135 
00136 // nsIWebBrowser methods
00137 - (void)addListener:(id <CHBrowserListener>)listener;
00138 - (void)removeListener:(id <CHBrowserListener>)listener;
00139 - (void)setContainer:(id <CHBrowserContainer>)container;
00140 - (nsIDOMWindow*)getContentWindow;
00141 
00142 // nsIWebNavigation methods
00143 - (void)loadURI:(NSString *)urlSpec referrer:(NSString*)referrer flags:(unsigned int)flags;
00144 - (void)reload:(unsigned int)flags;
00145 - (BOOL)canGoBack;
00146 - (BOOL)canGoForward;
00147 - (void)goBack;
00148 - (void)goForward;
00149 - (void)gotoIndex:(int)index;
00150 - (void)stop:(unsigned int)flags;
00151 - (NSString*)getCurrentURI;
00152 
00153 - (void)saveDocument: (NSView*)aFilterView filterList: (NSPopUpButton*)aFilterList;
00154 - (void)saveURL: (NSView*)aFilterView filterList: (NSPopUpButton*)aFilterList
00155             url: (NSString*)aURLSpec suggestedFilename: (NSString*)aFilename;
00156 
00157 - (void)printDocument;
00158 
00159 - (BOOL)findInPageWithPattern:(NSString*)inText caseSensitive:(BOOL)inCaseSensitive
00160             wrap:(BOOL)inWrap backwards:(BOOL)inBackwards;
00161 
00162 -(BOOL)validateMenuItem: (NSMenuItem*)aMenuItem;
00163 
00164 -(IBAction)cut:(id)aSender;
00165 -(BOOL)canCut;
00166 -(IBAction)copy:(id)aSender;
00167 -(BOOL)canCopy;
00168 -(IBAction)paste:(id)aSender;
00169 -(BOOL)canPaste;
00170 -(IBAction)delete:(id)aSender;
00171 -(BOOL)canDelete;
00172 -(IBAction)selectAll:(id)aSender;
00173 
00174 -(IBAction)undo:(id)aSender;
00175 -(IBAction)redo:(id)aSender;
00176 
00177 - (BOOL)canUndo;
00178 - (BOOL)canRedo;
00179 
00180 -(NSString*)getCurrentURLSpec;
00181 
00182 - (void)setActive: (BOOL)aIsActive;
00183 
00184 - (NSMenu*)getContextMenu;
00185 - (NSWindow*)getNativeWindow;
00186 
00187 - (void)destroyWebBrowser;
00188 - (nsIWebBrowser*)getWebBrowser;
00189 - (CHBrowserListener*)getCocoaBrowserListener;
00190 - (void)setWebBrowser:(nsIWebBrowser*)browser;
00191 
00192 - (NSString*)getFocusedURLString;
00193 
00194   // given a point in window coordinates, find the Gecko event sink of the ChildView the
00195   // point is over.
00196 - (void) findEventSink:(nsIEventSink**)outSink forPoint:(NSPoint)inPoint inWindow:(NSWindow*)inWind;
00197 
00198 @end
00199 
00200 #endif // __nsCocoaBrowserView_h__