This commit is contained in:
mcmullen%netscape.com 1999-03-26 23:55:32 +00:00
Родитель 46034eb399
Коммит 5c3eb74cd8
15 изменённых файлов: 1352 добавлений и 0 удалений

Просмотреть файл

@ -0,0 +1,15 @@
interface PrefsCore : BaseAppCore
{
/* IID: { 0x55af8384, 0xe11e, 0x11d2, \
{0x91, 0x5f, 0xa0, 0x53, 0xf0, 0x5f, 0xf7, 0xbc}} */
void PrefsCore();
void ChangePanel(in wstring url);
void PanelLoaded(in Window win);
void SavePrefs();
void CancelPrefs();
};

Просмотреть файл

@ -0,0 +1,67 @@
/* -*- 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 "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
/* AUTO-GENERATED. DO NOT EDIT!!! */
#ifndef nsIDOMPrefsCore_h__
#define nsIDOMPrefsCore_h__
#include "nsISupports.h"
#include "nsString.h"
#include "nsIScriptContext.h"
#include "nsIDOMBaseAppCore.h"
class nsIDOMWindow;
#define NS_IDOMPREFSCORE_IID \
{ 0x55af8384, 0xe11e, 0x11d2, \
{0x91, 0x5f, 0xa0, 0x53, 0xf0, 0x5f, 0xf7, 0xbc}}
class nsIDOMPrefsCore : public nsIDOMBaseAppCore {
public:
static const nsIID& GetIID() { static nsIID iid = NS_IDOMPREFSCORE_IID; return iid; }
NS_IMETHOD ChangePanel(const nsString& aUrl)=0;
NS_IMETHOD PanelLoaded(nsIDOMWindow* aWin)=0;
NS_IMETHOD SavePrefs()=0;
NS_IMETHOD CancelPrefs()=0;
};
#define NS_DECL_IDOMPREFSCORE \
NS_IMETHOD ChangePanel(const nsString& aUrl); \
NS_IMETHOD PanelLoaded(nsIDOMWindow* aWin); \
NS_IMETHOD SavePrefs(); \
NS_IMETHOD CancelPrefs(); \
#define NS_FORWARD_IDOMPREFSCORE(_to) \
NS_IMETHOD ChangePanel(const nsString& aUrl) { return _to##ChangePanel(aUrl); } \
NS_IMETHOD PanelLoaded(nsIDOMWindow* aWin) { return _to##PanelLoaded(aWin); } \
NS_IMETHOD SavePrefs() { return _to##SavePrefs(); } \
NS_IMETHOD CancelPrefs() { return _to##CancelPrefs(); } \
extern "C" NS_DOM nsresult NS_InitPrefsCoreClass(nsIScriptContext *aContext, void **aPrototype);
extern "C" NS_DOM nsresult NS_NewScriptPrefsCore(nsIScriptContext *aContext, nsISupports *aSupports, nsISupports *aParent, void **aReturn);
#endif // nsIDOMPrefsCore_h__

Просмотреть файл

@ -0,0 +1,464 @@
/* -*- 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 "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
/* AUTO-GENERATED. DO NOT EDIT!!! */
#include "jsapi.h"
#include "nsJSUtils.h"
#include "nscore.h"
#include "nsIScriptContext.h"
#include "nsIJSScriptObject.h"
#include "nsIScriptObjectOwner.h"
#include "nsIScriptGlobalObject.h"
#include "nsIPtr.h"
#include "nsString.h"
#include "nsIDOMPrefsCore.h"
#include "nsIDOMWindow.h"
#include "nsIScriptNameSpaceManager.h"
#include "nsRepository.h"
#include "nsDOMCID.h"
static NS_DEFINE_IID(kIScriptObjectOwnerIID, NS_ISCRIPTOBJECTOWNER_IID);
static NS_DEFINE_IID(kIJSScriptObjectIID, NS_IJSSCRIPTOBJECT_IID);
static NS_DEFINE_IID(kIScriptGlobalObjectIID, NS_ISCRIPTGLOBALOBJECT_IID);
static NS_DEFINE_IID(kIPrefsCoreIID, NS_IDOMPREFSCORE_IID);
static NS_DEFINE_IID(kIWindowIID, NS_IDOMWINDOW_IID);
NS_DEF_PTR(nsIDOMPrefsCore);
NS_DEF_PTR(nsIDOMWindow);
/***********************************************************************/
//
// PrefsCore Properties Getter
//
PR_STATIC_CALLBACK(JSBool)
GetPrefsCoreProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
{
nsIDOMPrefsCore *a = (nsIDOMPrefsCore*)JS_GetPrivate(cx, obj);
// If there's no private data, this must be the prototype, so ignore
if (nsnull == a) {
return JS_TRUE;
}
if (JSVAL_IS_INT(id)) {
switch(JSVAL_TO_INT(id)) {
case 0:
default:
return nsJSUtils::nsCallJSScriptObjectGetProperty(a, cx, id, vp);
}
}
else {
return nsJSUtils::nsCallJSScriptObjectGetProperty(a, cx, id, vp);
}
return PR_TRUE;
}
/***********************************************************************/
//
// PrefsCore Properties Setter
//
PR_STATIC_CALLBACK(JSBool)
SetPrefsCoreProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
{
nsIDOMPrefsCore *a = (nsIDOMPrefsCore*)JS_GetPrivate(cx, obj);
// If there's no private data, this must be the prototype, so ignore
if (nsnull == a) {
return JS_TRUE;
}
if (JSVAL_IS_INT(id)) {
switch(JSVAL_TO_INT(id)) {
case 0:
default:
return nsJSUtils::nsCallJSScriptObjectSetProperty(a, cx, id, vp);
}
}
else {
return nsJSUtils::nsCallJSScriptObjectSetProperty(a, cx, id, vp);
}
return PR_TRUE;
}
//
// PrefsCore finalizer
//
PR_STATIC_CALLBACK(void)
FinalizePrefsCore(JSContext *cx, JSObject *obj)
{
nsJSUtils::nsGenericFinalize(cx, obj);
}
//
// PrefsCore enumerate
//
PR_STATIC_CALLBACK(JSBool)
EnumeratePrefsCore(JSContext *cx, JSObject *obj)
{
return nsJSUtils::nsGenericEnumerate(cx, obj);
}
//
// PrefsCore resolve
//
PR_STATIC_CALLBACK(JSBool)
ResolvePrefsCore(JSContext *cx, JSObject *obj, jsval id)
{
return nsJSUtils::nsGenericResolve(cx, obj, id);
}
//
// Native method ChangePanel
//
PR_STATIC_CALLBACK(JSBool)
PrefsCoreChangePanel(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
nsIDOMPrefsCore *nativeThis = (nsIDOMPrefsCore*)JS_GetPrivate(cx, obj);
JSBool rBool = JS_FALSE;
nsAutoString b0;
*rval = JSVAL_NULL;
// If there's no private data, this must be the prototype, so ignore
if (nsnull == nativeThis) {
return JS_TRUE;
}
if (argc >= 1) {
nsJSUtils::nsConvertJSValToString(b0, cx, argv[0]);
if (NS_OK != nativeThis->ChangePanel(b0)) {
return JS_FALSE;
}
*rval = JSVAL_VOID;
}
else {
JS_ReportError(cx, "Function ChangePanel requires 1 parameters");
return JS_FALSE;
}
return JS_TRUE;
}
//
// Native method PanelLoaded
//
PR_STATIC_CALLBACK(JSBool)
PrefsCorePanelLoaded(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
nsIDOMPrefsCore *nativeThis = (nsIDOMPrefsCore*)JS_GetPrivate(cx, obj);
JSBool rBool = JS_FALSE;
nsIDOMWindowPtr b0;
*rval = JSVAL_NULL;
// If there's no private data, this must be the prototype, so ignore
if (nsnull == nativeThis) {
return JS_TRUE;
}
if (argc >= 1) {
if (JS_FALSE == nsJSUtils::nsConvertJSValToObject((nsISupports **)&b0,
kIWindowIID,
"Window",
cx,
argv[0])) {
return JS_FALSE;
}
if (NS_OK != nativeThis->PanelLoaded(b0)) {
return JS_FALSE;
}
*rval = JSVAL_VOID;
}
else {
JS_ReportError(cx, "Function PanelLoaded requires 1 parameters");
return JS_FALSE;
}
return JS_TRUE;
}
//
// Native method SavePrefs
//
PR_STATIC_CALLBACK(JSBool)
PrefsCoreSavePrefs(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
nsIDOMPrefsCore *nativeThis = (nsIDOMPrefsCore*)JS_GetPrivate(cx, obj);
JSBool rBool = JS_FALSE;
*rval = JSVAL_NULL;
// If there's no private data, this must be the prototype, so ignore
if (nsnull == nativeThis) {
return JS_TRUE;
}
if (argc >= 0) {
if (NS_OK != nativeThis->SavePrefs()) {
return JS_FALSE;
}
*rval = JSVAL_VOID;
}
else {
JS_ReportError(cx, "Function SavePrefs requires 0 parameters");
return JS_FALSE;
}
return JS_TRUE;
}
//
// Native method CancelPrefs
//
PR_STATIC_CALLBACK(JSBool)
PrefsCoreCancelPrefs(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
nsIDOMPrefsCore *nativeThis = (nsIDOMPrefsCore*)JS_GetPrivate(cx, obj);
JSBool rBool = JS_FALSE;
*rval = JSVAL_NULL;
// If there's no private data, this must be the prototype, so ignore
if (nsnull == nativeThis) {
return JS_TRUE;
}
if (argc >= 0) {
if (NS_OK != nativeThis->CancelPrefs()) {
return JS_FALSE;
}
*rval = JSVAL_VOID;
}
else {
JS_ReportError(cx, "Function CancelPrefs requires 0 parameters");
return JS_FALSE;
}
return JS_TRUE;
}
/***********************************************************************/
//
// class for PrefsCore
//
JSClass PrefsCoreClass = {
"PrefsCore",
JSCLASS_HAS_PRIVATE,
JS_PropertyStub,
JS_PropertyStub,
GetPrefsCoreProperty,
SetPrefsCoreProperty,
EnumeratePrefsCore,
ResolvePrefsCore,
JS_ConvertStub,
FinalizePrefsCore
};
//
// PrefsCore class properties
//
static JSPropertySpec PrefsCoreProperties[] =
{
{0}
};
//
// PrefsCore class methods
//
static JSFunctionSpec PrefsCoreMethods[] =
{
{"ChangePanel", PrefsCoreChangePanel, 1},
{"PanelLoaded", PrefsCorePanelLoaded, 1},
{"SavePrefs", PrefsCoreSavePrefs, 0},
{"CancelPrefs", PrefsCoreCancelPrefs, 0},
{0}
};
//
// PrefsCore constructor
//
PR_STATIC_CALLBACK(JSBool)
PrefsCore(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
nsresult result;
nsIID classID;
nsIScriptContext* context = (nsIScriptContext*)JS_GetContextPrivate(cx);
nsIScriptNameSpaceManager* manager;
nsIDOMPrefsCore *nativeThis;
nsIScriptObjectOwner *owner = nsnull;
static NS_DEFINE_IID(kIDOMPrefsCoreIID, NS_IDOMPREFSCORE_IID);
result = context->GetNameSpaceManager(&manager);
if (NS_OK != result) {
return JS_FALSE;
}
result = manager->LookupName("PrefsCore", PR_TRUE, classID);
NS_RELEASE(manager);
if (NS_OK != result) {
return JS_FALSE;
}
result = nsRepository::CreateInstance(classID,
nsnull,
kIDOMPrefsCoreIID,
(void **)&nativeThis);
if (NS_OK != result) {
return JS_FALSE;
}
// XXX We should be calling Init() on the instance
result = nativeThis->QueryInterface(kIScriptObjectOwnerIID, (void **)&owner);
if (NS_OK != result) {
NS_RELEASE(nativeThis);
return JS_FALSE;
}
owner->SetScriptObject((void *)obj);
JS_SetPrivate(cx, obj, nativeThis);
NS_RELEASE(owner);
return JS_TRUE;
}
//
// PrefsCore class initialization
//
extern "C" NS_DOM nsresult NS_InitPrefsCoreClass(nsIScriptContext *aContext, void **aPrototype)
{
JSContext *jscontext = (JSContext *)aContext->GetNativeContext();
JSObject *proto = nsnull;
JSObject *constructor = nsnull;
JSObject *parent_proto = nsnull;
JSObject *global = JS_GetGlobalObject(jscontext);
jsval vp;
if ((PR_TRUE != JS_LookupProperty(jscontext, global, "PrefsCore", &vp)) ||
!JSVAL_IS_OBJECT(vp) ||
((constructor = JSVAL_TO_OBJECT(vp)) == nsnull) ||
(PR_TRUE != JS_LookupProperty(jscontext, JSVAL_TO_OBJECT(vp), "prototype", &vp)) ||
!JSVAL_IS_OBJECT(vp)) {
if (NS_OK != NS_InitBaseAppCoreClass(aContext, (void **)&parent_proto)) {
return NS_ERROR_FAILURE;
}
proto = JS_InitClass(jscontext, // context
global, // global object
parent_proto, // parent proto
&PrefsCoreClass, // JSClass
PrefsCore, // JSNative ctor
0, // ctor args
PrefsCoreProperties, // proto props
PrefsCoreMethods, // proto funcs
nsnull, // ctor props (static)
nsnull); // ctor funcs (static)
if (nsnull == proto) {
return NS_ERROR_FAILURE;
}
}
else if ((nsnull != constructor) && JSVAL_IS_OBJECT(vp)) {
proto = JSVAL_TO_OBJECT(vp);
}
else {
return NS_ERROR_FAILURE;
}
if (aPrototype) {
*aPrototype = proto;
}
return NS_OK;
}
//
// Method for creating a new PrefsCore JavaScript object
//
extern "C" NS_DOM nsresult NS_NewScriptPrefsCore(nsIScriptContext *aContext, nsISupports *aSupports, nsISupports *aParent, void **aReturn)
{
NS_PRECONDITION(nsnull != aContext && nsnull != aSupports && nsnull != aReturn, "null argument to NS_NewScriptPrefsCore");
JSObject *proto;
JSObject *parent;
nsIScriptObjectOwner *owner;
JSContext *jscontext = (JSContext *)aContext->GetNativeContext();
nsresult result = NS_OK;
nsIDOMPrefsCore *aPrefsCore;
if (nsnull == aParent) {
parent = nsnull;
}
else if (NS_OK == aParent->QueryInterface(kIScriptObjectOwnerIID, (void**)&owner)) {
if (NS_OK != owner->GetScriptObject(aContext, (void **)&parent)) {
NS_RELEASE(owner);
return NS_ERROR_FAILURE;
}
NS_RELEASE(owner);
}
else {
return NS_ERROR_FAILURE;
}
if (NS_OK != NS_InitPrefsCoreClass(aContext, (void **)&proto)) {
return NS_ERROR_FAILURE;
}
result = aSupports->QueryInterface(kIPrefsCoreIID, (void **)&aPrefsCore);
if (NS_OK != result) {
return result;
}
// create a js object for this class
*aReturn = JS_NewObject(jscontext, &PrefsCoreClass, proto, parent);
if (nsnull != *aReturn) {
// connect the native object to the js object
JS_SetPrivate(jscontext, (JSObject *)*aReturn, aPrefsCore);
}
else {
NS_RELEASE(aPrefsCore);
return NS_ERROR_FAILURE;
}
return NS_OK;
}

Просмотреть файл

@ -0,0 +1,207 @@
/* -*- 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.
*/
#include "nsPrefsCore.h"
#include "nsIBrowserWindow.h"
#include "nsIWebShell.h"
#include "pratom.h"
#include "nsIComponentManager.h"
#include "nsAppCores.h"
#include "nsAppCoresCIDs.h"
#include "nsAppCoresManager.h"
#include "nsIScriptGlobalObject.h"
#include "nsIScriptContext.h"
#include "nsIScriptContextOwner.h"
#include "nsIDOMDocument.h"
#include "nsIDocument.h"
#include "nsIDOMWindow.h"
#include "nsIWebShellWindow.h"
// Globals
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
static NS_DEFINE_IID(kIPrefsCoreIID, NS_IDOMPREFSCORE_IID);
static NS_DEFINE_IID(kIDOMDocumentIID, nsIDOMDocument::GetIID());
static NS_DEFINE_IID(kIDocumentIID, nsIDocument::GetIID());
static NS_DEFINE_IID(kPrefsCoreCID, NS_PREFSCORE_CID);
static NS_DEFINE_IID(kBrowserWindowCID, NS_BROWSER_WINDOW_CID);
//----------------------------------------------------------------------------------------
nsPrefsCore::nsPrefsCore()
//----------------------------------------------------------------------------------------
: mTreeScriptContext(nsnull)
, mPanelScriptContext(nsnull)
, mTreeWindow(nsnull)
, mPanelWindow(nsnull)
{
printf("Created nsPrefsCore\n");
}
//----------------------------------------------------------------------------------------
nsPrefsCore::~nsPrefsCore()
//----------------------------------------------------------------------------------------
{
NS_IF_RELEASE(mTreeScriptContext);
NS_IF_RELEASE(mPanelScriptContext);
NS_IF_RELEASE(mTreeWindow);
NS_IF_RELEASE(mPanelWindow);
}
NS_IMPL_ISUPPORTS_INHERITED(nsPrefsCore, nsBaseAppCore, nsIDOMPrefsCore)
//----------------------------------------------------------------------------------------
NS_IMETHODIMP nsPrefsCore::GetScriptObject(nsIScriptContext *aContext, void** aScriptObject)
//----------------------------------------------------------------------------------------
{
NS_PRECONDITION(nsnull != aScriptObject, "null arg");
nsresult res = NS_OK;
if (nsnull == mScriptObject)
{
res = NS_NewScriptPrefsCore(aContext,
(nsISupports *)(nsIDOMPrefsCore*)this,
nsnull,
&mScriptObject);
}
*aScriptObject = mScriptObject;
return res;
}
//----------------------------------------------------------------------------------------
NS_IMETHODIMP nsPrefsCore::Init(const nsString& aId)
//----------------------------------------------------------------------------------------
{
return nsBaseAppCore::Init(aId);
}
#if 0
//----------------------------------------------------------------------------------------
NS_IMETHODIMP nsPrefsCore::SetPrefsTree(nsIDOMWindow* aWin)
//----------------------------------------------------------------------------------------
{
if (!aWin)
return NS_OK;
mTreeWindow = aWin;
NS_ADDREF(aWin);
mTreeScriptContext = GetScriptContext(aWin);
return NS_OK;
}
#endif // 0
//----------------------------------------------------------------------------------------
NS_IMETHODIMP nsPrefsCore::ChangePanel(const nsString& aURL)
// Start loading of a new prefs panel.
//----------------------------------------------------------------------------------------
{
NS_ASSERTION(mPanelWindow, "panel window is null");
if (!mPanelWindow)
return NS_OK;
nsCOMPtr<nsIScriptGlobalObject> globalScript(do_QueryInterface(mPanelWindow));
if (!globalScript)
return NS_ERROR_FAILURE;
nsCOMPtr<nsIWebShell> webshell;
globalScript->GetWebShell(getter_AddRefs(webshell));
if (!webshell)
return NS_ERROR_FAILURE;
webshell->LoadURL(aURL);
return NS_OK;
}
//----------------------------------------------------------------------------------------
NS_IMETHODIMP nsPrefsCore::PanelLoaded(nsIDOMWindow* aWin)
// Callback after loading of a new prefs panel.
//----------------------------------------------------------------------------------------
{
if (mPanelWindow == aWin)
return NS_OK;
if (mPanelWindow)
NS_RELEASE(mPanelWindow);
mPanelWindow = aWin;
if (!aWin)
return NS_OK;
NS_ADDREF(aWin);
mPanelScriptContext = GetScriptContext(aWin);
return NS_OK;
}
//----------------------------------------------------------------------------------------
static nsCOMPtr<nsIWebShellWindow>
DOMWindowToWebShellWindow(nsIDOMWindow *DOMWindow)
// horribly complicated routine simply to convert from one to the other
//----------------------------------------------------------------------------------------
{
nsCOMPtr<nsIWebShellWindow> webWindow;
nsCOMPtr<nsIScriptGlobalObject> globalScript(do_QueryInterface(DOMWindow));
nsCOMPtr<nsIWebShell> webshell;
if (globalScript)
globalScript->GetWebShell(getter_AddRefs(webshell));
if (webshell)
{
nsCOMPtr<nsIWebShellContainer> webshellContainer;
webshell->GetContainer(*getter_AddRefs(webshellContainer));
webWindow = do_QueryInterface(webshellContainer);
}
return webWindow;
}
//----------------------------------------------------------------------------------------
static nsresult Close(nsIDOMWindow*& dw)
//----------------------------------------------------------------------------------------
{
if (!dw)
return NS_ERROR_FAILURE;
nsIDOMWindow* top;
dw->GetTop(&top);
if (!top)
return NS_ERROR_FAILURE;
nsCOMPtr<nsIWebShellWindow> parent = DOMWindowToWebShellWindow(top);
if (parent)
parent->Close();
NS_IF_RELEASE(dw);
return NS_OK;
}
//----------------------------------------------------------------------------------------
NS_IMETHODIMP nsPrefsCore::SavePrefs()
//----------------------------------------------------------------------------------------
{
// Do the prefs stuff...
// Then close
return Close(mPanelWindow);
}
//----------------------------------------------------------------------------------------
NS_IMETHODIMP nsPrefsCore::CancelPrefs()
//----------------------------------------------------------------------------------------
{
// Do the prefs stuff...
// Then close
return Close(mPanelWindow);
}

Просмотреть файл

@ -0,0 +1,67 @@
/* -*- 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 "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#ifndef nsPrefsCorePrivate_h___
#define nsPrefsCorePrivate_h___
//#include "nsAppCores.h"
#include "nscore.h"
#include "nsString.h"
#include "nsISupports.h"
#include "nsIDOMPrefsCore.h"
#include "nsBaseAppCore.h"
class nsIBrowserWindow;
class nsIWebShell;
class nsIScriptContext;
class nsIDOMWindow;
//========================================================================================
class nsPrefsCore
//========================================================================================
: public nsBaseAppCore
, public nsIDOMPrefsCore
{
public:
nsPrefsCore();
virtual ~nsPrefsCore();
NS_DECL_ISUPPORTS_INHERITED
NS_IMETHOD GetScriptObject(nsIScriptContext *aContext, void** aScriptObject);
NS_IMETHOD Init(const nsString& aId);
NS_IMETHOD GetId(nsString& aId) { return nsBaseAppCore::GetId(aId); }
NS_IMETHOD SetDocumentCharset(const nsString& aCharset) { return nsBaseAppCore::SetDocumentCharset(aCharset); }
NS_DECL_IDOMPREFSCORE
protected:
nsString mTreeScript;
nsString mPanelScript;
nsIScriptContext* mTreeScriptContext;
nsIScriptContext* mPanelScriptContext;
nsIDOMWindow* mTreeWindow;
nsIDOMWindow* mPanelWindow;
};
#endif // nsPrefsCore_h___

Просмотреть файл

Просмотреть файл

Просмотреть файл

@ -0,0 +1,21 @@
<html>
<head>
<script language="JavaScript" src="PrefsWindow.js">
</script>
</head>
<FRAMESET Rows="*,40" onload = "return StartUp('Top');" border=no>
<FRAMESET cols="128,*" >
<FRAME NAME=preftree SRC="preftree.xul" scrolling="auto" border="yes">
<FRAME NAME=prefpane SRC="pref-appearance.html" scrolling="no" border="no">
</FRAMESET>
<FRAME NAME=prefbottom SRC="prefbottom.html" border="no" scrolling="no">
</FRAMESET>
</html>

Просмотреть файл

@ -0,0 +1,40 @@
var prefsCore;
function StartUp(windowName)
{
dump("\nDoing " + windowName + " startup...\n");
prefsCore = XPAppCoresManager.Find("PrefsCore");
dump("Looking up PrefsCore...\n");
if (prefsCore == null)
{
dump("Creating PrefsCore...\n");
prefsCore = new PrefsCore();
if (prefsCore != null)
{
dump("PrefsCore has been created.\n");
prefsCore.Init("PrefsCore");
if (windowName != "Top" && windowName != "Bottom")
{
prefsCore.PanelLoaded(window);
}
}
else
{
dump("PrefsCore was not created");
}
}
else
{
dump("PrefsCore has already been created! Hurrah!\n");
}
}
function DoSave()
{
prefsCore.SavePrefs();
}
function DoCancel()
{
prefsCore.CancelPrefs();
}

Просмотреть файл

@ -0,0 +1,69 @@
<html>
<head>
<title>Sample Prefs Panel</title>
</head>
<style>
body {
background-color:#CCCCCC
}
#righttext {
text-align: left;
font-style: bold;
}
#righttext {
text-align: right;
}
#top {
background-color: grey
}
// table {
// display:block;
// border: groove white 2px;
// min-height: 16px;
// color: white;
// }
</style>
<script language="JavaScript" src="PrefsWindow.js">
</script>
<body ID=here onload="return StartUp('Appearance');">
<DIV ID=top>
<SPAN ID=lefttext>Appearance</SPAN>
</DIV>
<br>
On startup, launch
<FORM>
<table>
<tr><td><input type="checkbox">Navigator</td></tr>
<tr><td><input type="checkbox">Messenger</td></tr>
<tr><td><input type="checkbox">Composer</td></tr>
<tr><td><input type="checkbox">Calendar</td></tr>
</table>
</FORM>
<br>
<br>
Show toolbars as
<FORM>
<table>
<tr><td><input name="showtoolbar" type="radio">Pictures and Text</td></tr>
<tr><td><input name="showtoolbar" type="radio">Pictures Only</td></tr>
<tr><td><input name="showtoolbar" type="radio">Text Only</td></tr>
</table>
</FORM>
</body>
</html>

Просмотреть файл

@ -0,0 +1,16 @@
<html>
<head>
<title>Sample Prefs Panel</title>
</head>
<script language="JavaScript" src="PrefsWindow.js">
</script>
<body bgcolor="#FF0000" text="#000000" onload="return StartUp('Fonts')">
<h1>Fonts panel</h1>
<P>Watch this space...</P>
</body>
</html>

Просмотреть файл

@ -0,0 +1,90 @@
<style>
body {
background-color:#CCCCCC
}
#righttext {
text-align: left;
font-style: bold;
}
#righttext {
text-align: right;
}
#top {
background-color: grey
}
#tableb {
display:block;
border: groove white 2px;
font-size: 7pt;
min-height: 16px;
color: white;
}
</style>
<head>
<script language="JavaScript" src="PrefsWindow.js">
</script>
</head>
<body ID=here onload="return StartUp('Navigator')">
<DIV ID=top>
<SPAN ID=lefttext>Navigator</SPAN>
</DIV>
<br>
Navigator starts with
<table ID="tableb">
<tr>
<FORM>
<tr><td><input name=starts type="radio">Blank Page</td></tr>
<tr><td><input name=starts type="radio">Home Page</td></tr>
<tr><td><input name=starts type="radio">Last Page vistited</td></tr>
</FORM>
</table>
Home page
<table ID="tableb">
<tr>
<tr><td>Clicking the Home button will take you to this page.<td><tr>
<FORM>
<tr><td>Location: <input name="homepage" type="text" value="http://my.netscape.com" size="20"><td>
<tr><td><input name=starts type="button" value="Use Current Page">
<input name="browse" type="button" value="browsefile"><td></tr>
</FORM>
</table>
History
<table ID="tableb">
<tr>
<FORM>
History is a list of the pages you have previously vistited.
<td>Pages in history expire after:<input type="text" value="9" size=3>days</td>
<td><input name="Clearit" type="button" value="Clear History"></td>
</FORM>
</table>
Home page
<table ID="tableb">
<tr>
<FORM>
<tr><td>Clear the list of sites on the location bar: <input name=starts type="button" value="Clear Location Bar"><td>
</FORM>
</table>
<br>
<br>
</body>

Просмотреть файл

@ -0,0 +1,53 @@
<html>
<head>
<script language="JavaScript" src="PrefsWindow.js">
</script>
</head>
<style>
body {
background-color:#CCCCCC
}
#lefttext {
text-align: left;
font-style: bold;
}
#righttext {
text-align: right;
}
#top {
font-family:system;
background-color: grey
}
</style>
<body onload="return StartUp('Bottom');">
<table width="100%" cellpadding=0 cellspacing=0>
<tr>
<td valign="right" width="160">
<center>
<form>
<input type="button" align="bottom" value="Help">
</input>
<input type="button" align="bottom" value="Cancel" onclick="DoSave();">
</input>
<input type="button" align="bottom" value="OK" onClick="DoCancel();">
</input>
</form>
</center>
</td>
</tr>
</table>
</body>
</html>

Просмотреть файл

@ -0,0 +1,63 @@
window {
display: block;
width: 100%;
border: thin black solid bottom;
}
tree {
display: table;
background-color: white;
border: none;
border-spacing: 0px;
border-collapse: collapse;
width: 100%;
}
treeitem {
display: table-row;
visibility: visible;
}
treehead {
display: table-header-group;
}
treebody {
display: table-row-group;
}
treehead > treeitem {
visibility: visible;
}
treeitem[open] > treechildren > treeitem {
visibility: visible;
}
treebody > treeitem {
visibility: visible;
}
treecell {
display: table-cell;
color: black;
font-family: Arial;
font-size: 12pt;
}
treehead treeitem treecell {
background-color: white;
border: thin black solid;
color: black;
}
treeicon {
display: list-item;
list-style-image: url("http://rava/~hyatt/ClosedRead.gif");
list-style-position: inside;
}
treecell[selectedcell] {
background-color: yellow;
}

Просмотреть файл

@ -0,0 +1,180 @@
<?xml version="1.0"?>
<?xml-stylesheet href="preftree.css" type="text/css"?>
<!DOCTYPE window>
<xul:window xmlns:html="http://www.w3.org/TR/REC-html40"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
onload = "ChangePanelURL(pref-appearance.html);">
<html:script>
function ClickChangePanel(node)
{
url = node.getAttribute('name');
ChangePanelURL(url);
}
function ChangePanelURL(url)
{
dump("ChangePanel(" + url + ")\n");
var prefsCore = XPAppCoresManager.Find("PrefsCore");
if (!prefsCore)
{
prefsCore = new PrefsCore();
if (prefsCore)
{
prefsCore.Init("PrefsCore");
}
}
if (prefsCore)
{
prefsCore.ChangePanel(url);
}
return true;
}
</html:script>
<tree onclick="return ClickChangePanel(event.target);">
<treebody>
<treeitem>
<treecell name="resource:/res/samples/pref-appearance.html"><treeindentation/>Appearance</treecell>
<treechildren>
<treeitem>
<treecell name="resource:/res/samples/pref-fonts.html"><treeindentation/>Fonts</treecell>
</treeitem>
<treeitem>
<treecell><treeindentation/>Colors</treecell>
</treeitem>
</treechildren>
</treeitem>
<treeitem>
<treecell name="resource:/res/samples/pref-navigator.html"><treeindentation/>Navigator</treecell>
<treechildren>
<treeitem>
<treecell><treeindentation/>Languages</treecell>
</treeitem>
<treeitem>
<treecell><treeindentation/>Applications</treecell>
</treeitem>
<treeitem>
<treecell><treeindentation/>Smart Browsing</treecell>
</treeitem>
</treechildren>
</treeitem>
<treeitem>
<treecell><treeindentation/>Mail & News</treecell>
<treechildren>
<treeitem>
<treecell><treeindentation/>Identity</treecell>
</treeitem>
<treeitem>
<treecell><treeindentation/>Mail Servers</treecell>
</treeitem>
<treeitem>
<treecell><treeindentation/>News Servers</treecell>
</treeitem>
<treeitem>
<treecell><treeindentation/>Addressing</treecell>
</treeitem>
<treeitem>
<treecell><treeindentation/>Messages</treecell>
</treeitem>
<treeitem>
<treecell><treeindentation/>Window Settings</treecell>
</treeitem>
<treeitem>
<treecell><treeindentation/>Copies & Folders</treecell>
</treeitem>
<treeitem>
<treecell><treeindentation/>Formatting</treecell>
</treeitem>
<treeitem>
<treecell><treeindentation/>Return Receipts</treecell>
</treeitem>
<treeitem>
<treecell><treeindentation/>Disk Space</treecell>
</treeitem>
</treechildren>
</treeitem>
<treeitem>
<treecell><treeindentation/>Composer</treecell>
<treechildren>
<treeitem>
<treecell><treeindentation/>Publish</treecell>
</treeitem>
</treechildren>
</treeitem>
<treeitem>
<treecell><treeindentation/>Roaming Access</treecell>
<treechildren>
<treeitem>
<treecell><treeindentation/>Server Info</treecell>
</treeitem>
<treeitem>
<treecell><treeindentation/>File Selection</treecell>
</treeitem>
</treechildren>
</treeitem>
<treeitem>
<treecell><treeindentation/>Offline</treecell>
<treechildren>
<treeitem>
<treecell><treeindentation/>Download</treecell>
</treeitem>
</treechildren>
</treeitem>
<treeitem>
<treecell><treeindentation/>Advanced</treecell>
<treechildren>
<treeitem>
<treecell><treeindentation/>Publish</treecell>
</treeitem>
<treeitem>
<treecell><treeindentation/>Cache</treecell>
</treeitem>
<treeitem>
<treecell><treeindentation/>Proxies</treecell>
</treeitem>
<treeitem>
<treecell><treeindentation/>Smart Update</treecell>
</treeitem>
</treechildren>
</treeitem>
</treebody>
</tree>
</window>