gecko-dev/webshell/tests/viewer/nsBrowserWindow.h

251 строка
7.8 KiB
C
Исходник Обычный вид История

1998-07-21 01:15:52 +04:00
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
* the License for the specific language governing rights and limitations
* under the License.
*
* The Original Code is Mozilla Communicator client code.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corporation. Portions created by Netscape are Copyright (C) 1998
* Netscape Communications Corporation. All Rights Reserved.
*/
#ifndef nsBrowserWindow_h___
#define nsBrowserWindow_h___
#include "nsIBrowserWindow.h"
#include "nsIStreamListener.h"
#include "nsINetSupport.h"
1998-07-21 01:15:52 +04:00
#include "nsIWebShell.h"
#include "nsIScriptContextOwner.h"
#include "nsString.h"
#include "nsVoidArray.h"
#include "nsCRT.h"
1998-09-24 03:02:54 +04:00
//#include "nsIPref.h"
1998-07-31 22:34:53 +04:00
1998-08-28 20:14:37 +04:00
class nsILabel;
class nsICheckButton;
class nsIRadioButton;
class nsIDialog;
1998-07-21 01:15:52 +04:00
class nsITextWidget;
class nsIButton;
class nsIThrobber;
class nsViewerApp;
class nsIDocumentViewer;
class nsIPresContext;
class nsIPresShell;
1998-07-31 22:34:53 +04:00
class nsIPref;
class nsIContentConnector;
#define SAMPLES_BASE_URL "resource:/res/samples"
1998-07-21 01:15:52 +04:00
/**
* Abstract base class for our test app's browser windows
*/
class nsBrowserWindow : public nsIBrowserWindow,
public nsIStreamObserver,
public nsINetSupport,
public nsIWebShellContainer
1998-07-21 01:15:52 +04:00
{
public:
void* operator new(size_t sz) {
void* rv = new char[sz];
nsCRT::zero(rv, sz);
return rv;
}
// nsISupports
NS_DECL_ISUPPORTS
// nsIBrowserWindow
NS_IMETHOD Init(nsIAppShell* aAppShell,
1998-07-31 10:02:06 +04:00
nsIPref* aPrefs,
1998-07-21 01:15:52 +04:00
const nsRect& aBounds,
1998-08-05 08:23:21 +04:00
PRUint32 aChromeMask,
PRBool aAllowPlugins = PR_TRUE);
1998-07-21 01:15:52 +04:00
NS_IMETHOD MoveTo(PRInt32 aX, PRInt32 aY);
NS_IMETHOD SizeTo(PRInt32 aWidth, PRInt32 aHeight);
NS_IMETHOD GetBounds(nsRect& aBounds);
NS_IMETHOD GetWindowBounds(nsRect& aBounds);
1998-07-21 01:15:52 +04:00
NS_IMETHOD Show();
NS_IMETHOD Hide();
NS_IMETHOD Close();
NS_IMETHOD SetChrome(PRUint32 aNewChromeMask);
1998-07-21 01:15:52 +04:00
NS_IMETHOD GetChrome(PRUint32& aChromeMaskResult);
NS_IMETHOD SetTitle(const PRUnichar* aTitle);
NS_IMETHOD GetTitle(PRUnichar** aResult);
NS_IMETHOD SetStatus(const PRUnichar* aStatus);
NS_IMETHOD GetStatus(PRUnichar** aResult);
NS_IMETHOD SetProgress(PRInt32 aProgress, PRInt32 aProgressMax);
NS_IMETHOD GetWebShell(nsIWebShell*& aResult);
1998-07-21 01:15:52 +04:00
// nsIStreamObserver
NS_IMETHOD OnStartBinding(nsIURL* aURL, const char *aContentType);
NS_IMETHOD OnProgress(nsIURL* aURL, PRInt32 aProgress, PRInt32 aProgressMax);
NS_IMETHOD OnStatus(nsIURL* aURL, const nsString& aMsg);
NS_IMETHOD OnStopBinding(nsIURL* aURL, PRInt32 status, const nsString &aMsg);
1998-07-21 01:15:52 +04:00
// nsIWebShellContainer
NS_IMETHOD WillLoadURL(nsIWebShell* aShell, const PRUnichar* aURL, nsLoadType aReason);
NS_IMETHOD BeginLoadURL(nsIWebShell* aShell, const PRUnichar* aURL);
NS_IMETHOD ProgressLoadURL(nsIWebShell* aShell, const PRUnichar* aURL, PRInt32 aProgress, PRInt32 aProgressMax);
NS_IMETHOD EndLoadURL(nsIWebShell* aShell, const PRUnichar* aURL, PRInt32 aStatus);
1998-12-08 05:39:48 +03:00
NS_IMETHOD NewWebShell(PRUint32 aChromeMask,
PRBool aVisible,
nsIWebShell *&aNewWebShell);
1998-09-18 04:35:55 +04:00
NS_IMETHOD FindWebShellWithName(const PRUnichar* aName, nsIWebShell*& aResult);
NS_IMETHOD FocusAvailable(nsIWebShell* aFocusedWebShell);
1998-07-21 01:15:52 +04:00
// nsINetSupport
NS_IMETHOD_(void) Alert(const nsString &aText);
NS_IMETHOD_(PRBool) Confirm(const nsString &aText);
NS_IMETHOD_(PRBool) Prompt(const nsString &aText,
const nsString &aDefault,
nsString &aResult);
NS_IMETHOD_(PRBool) PromptUserAndPassword(const nsString &aText,
nsString &aUser,
nsString &aPassword);
NS_IMETHOD_(PRBool) PromptPassword(const nsString &aText,
nsString &aPassword);
1998-07-21 01:15:52 +04:00
// nsBrowserWindow
virtual nsresult CreateMenuBar(PRInt32 aWidth) = 0;
virtual nsresult CreateToolBar(PRInt32 aWidth);
virtual nsresult CreateStatusBar(PRInt32 aWidth);
void Layout(PRInt32 aWidth, PRInt32 aHeight);
void Back();
void Forward();
1998-11-11 23:31:45 +03:00
void GoTo(const PRUnichar* aURL,const char* aCommand=nsnull);
1998-07-21 01:15:52 +04:00
void StartThrobber();
void StopThrobber();
void LoadThrobberImages();
void DestroyThrobberImages();
1998-07-21 02:13:11 +04:00
virtual nsEventStatus DispatchMenuItem(PRInt32 aID) = 0;
1998-07-21 01:15:52 +04:00
void DoFileOpen();
void DoCopy();
void DoJSConsole();
1998-09-22 04:57:54 +04:00
void DoPrefs();
1998-08-14 05:51:00 +04:00
void DoEditorMode(nsIWebShell* aWebShell);
nsIPresShell* GetPresShell();
1998-08-28 20:14:37 +04:00
void DoFind();
void DoSelectAll();
NS_IMETHOD FindNext(const nsString &aSearchStr, PRBool aMatchCase, PRBool aSearchDown, PRBool &aIsFound);
NS_IMETHOD ForceRefresh();
void DoTreeView();
void ShowPrintPreview(PRInt32 aID);
1998-11-14 04:58:34 +03:00
void DoPrint(void);
1998-07-21 01:15:52 +04:00
#ifdef NS_DEBUG
void DumpContent(FILE *out = stdout);
void DumpFrames(FILE *out = stdout, nsString *aFilter = nsnull);
1998-07-21 01:15:52 +04:00
void DumpViews(FILE *out = stdout);
void DumpWebShells(FILE *out = stdout);
void DumpStyleSheets(FILE *out = stdout);
void DumpStyleContexts(FILE *out = stdout);
void ToggleFrameBorders();
void ShowContentSize();
void ShowFrameSize();
void ShowStyleSize();
1998-07-21 02:22:13 +04:00
void DoDebugSave();
void DoToggleSelection();
void DoDebugRobot();
void DoSiteWalker();
1998-07-21 02:13:11 +04:00
nsEventStatus DispatchDebugMenu(PRInt32 aID);
1998-09-24 03:02:54 +04:00
void SetCompatibilityMode(PRBool aIsStandard);
1998-07-21 01:15:52 +04:00
#endif
1998-08-28 20:14:37 +04:00
nsEventStatus ProcessDialogEvent(nsGUIEvent *aEvent);
// Initialize a second view on a different browser windows document
// viewer.
nsresult Init(nsIAppShell* aAppShell,
nsIPref* aPrefs,
const nsRect& aBounds,
PRUint32 aChromeMask,
PRBool aAllowPlugins,
nsIDocumentViewer* aDocViewer,
nsIPresContext* aPresContext);
1998-08-28 20:14:37 +04:00
1998-07-21 01:15:52 +04:00
void SetApp(nsViewerApp* aApp) {
mApp = aApp;
}
static void CloseAllWindows();
1998-07-21 01:15:52 +04:00
nsViewerApp* mApp;
PRUint32 mChromeMask;
nsString mTitle;
nsIWidget* mWindow;
nsIWebShell* mWebShell;
// "Toolbar"
nsITextWidget* mLocation;
nsIButton* mBack;
nsIButton* mForward;
nsIThrobber* mThrobber;
nsIContentConnector* mTreeView;
1998-07-21 01:15:52 +04:00
// "Status bar"
nsITextWidget* mStatus;
1998-08-28 20:14:37 +04:00
// Find Dialog
nsIDialog * mDialog;
nsIButton * mCancelBtn;
nsIButton * mFindBtn;
nsITextWidget * mTextField;
nsICheckButton * mMatchCheckBtn;
nsIRadioButton * mUpRadioBtn;
nsIRadioButton * mDwnRadioBtn;
nsILabel * mLabel;
//for creating more instances
nsIAppShell* mAppShell;
nsIPref* mPrefs;
PRBool mAllowPlugins;
1998-07-21 01:15:52 +04:00
// Global window collection
static nsVoidArray gBrowsers;
static void AddBrowser(nsBrowserWindow* aBrowser);
static void RemoveBrowser(nsBrowserWindow* aBrowser);
static nsBrowserWindow* FindBrowserFor(nsIWidget* aWidget, PRIntn aWhich);
protected:
nsBrowserWindow();
virtual ~nsBrowserWindow();
};
// XXX This is bad; because we can't hang a closure off of the event
// callback we have no way to store our This pointer; therefore we
// have to hunt to find the browswer that events belong too!!!
// aWhich for FindBrowserFor
#define FIND_WINDOW 0
#define FIND_BACK 1
#define FIND_FORWARD 2
#define FIND_LOCATION 3
//----------------------------------------------------------------------
class nsNativeBrowserWindow : public nsBrowserWindow {
public:
nsNativeBrowserWindow();
~nsNativeBrowserWindow();
virtual nsresult CreateMenuBar(PRInt32 aWidth);
1998-07-21 02:13:11 +04:00
virtual nsEventStatus DispatchMenuItem(PRInt32 aID);
1998-07-21 01:15:52 +04:00
};
#endif /* nsBrowserWindow_h___ */