Removing ApplicationShell interfaces from webshell. Will be moved to toplevel 'shell' in near future.

This commit is contained in:
spider 1998-05-04 19:25:58 +00:00
Родитель 9ad3d2ec08
Коммит cd74c826b1
17 изменённых файлов: 3 добавлений и 1391 удалений

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

@ -20,11 +20,9 @@ DEPTH = ../..
MODULE = raptor
EXPORTS = \
nsIApplicationShell.h \
nsIDocumentWidget.h \
nsILinkHandler.h \
nsIWebWidget.h \
nsIShellInstance.h \
nsweb.h \
$(NULL)

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

@ -23,9 +23,7 @@ MODULE=raptor
EXPORTS = \
nsIDocumentWidget.h \
nsIApplicationShell.h \
nsILinkHandler.h \
nsIShellInstance.h \
nsIWebWidget.h \
nsweb.h \
$(NULL)

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

@ -1,50 +0,0 @@
/* -*- 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 nsIApplicationShell_h___
#define nsIApplicationShell_h___
#include "nsISupports.h"
#include "nsweb.h"
#include "nscore.h"
#define NS_IAPPLICATIONSHELL_IID \
{ 0xaf9a93e0, 0xdebc, 0x11d1, \
{0x92, 0x44, 0x00, 0x80, 0x5f, 0x8a, 0x7a, 0xb6} }
//2293d960-deff-11d1-9244-00805f8a7ab6
#define NS_IAPPLICATIONSHELL_CID \
{ 0x2293d960, 0xdeff, 0x11d1, \
{0x92, 0x44, 0x00, 0x80, 0x5f, 0x8a, 0x7a, 0xb6} }
// All Applications must implement this C interface
extern "C" nsresult NS_RegisterApplicationShellFactory();
// Interface to the application shell.
class nsIApplicationShell : public nsISupports {
public:
// Create a native window for this web widget; may be called once
NS_IMETHOD Init() = 0;
NS_IMETHOD Run() = 0;
};
extern NS_WEB nsresult NS_NewApplicationShell(nsIApplicationShell** aInstancePtrResult);
#endif /* nsIApplicationShell_h___ */

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

@ -1,48 +0,0 @@
/* -*- 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 nsIShellInstance_h___
#define nsIShellInstance_h___
#include "nsISupports.h"
#include "nsIApplicationShell.h"
#include "nsweb.h"
#include "nscore.h"
// bf88e640-df99-11d1-9244-00805f8a7ab6
#define NS_ISHELLINSTANCE_IID \
{ 0xbf88e640, 0xdf99, 0x11d1, \
{0x92, 0x44, 0x00, 0x80, 0x5f, 0x8a, 0x7a, 0xb6} }
// Interface to the application shell.
class nsIShellInstance : public nsISupports {
public:
// Create a native window for this web widget; may be called once
NS_IMETHOD Init() = 0;
NS_IMETHOD Run() = 0;
NS_IMETHOD_(void *) GetNativeInstance() = 0;
NS_IMETHOD_(void) SetNativeInstance(void * aNativeInstance) = 0;
NS_IMETHOD_(nsIApplicationShell *) GetApplicationShell() = 0;
NS_IMETHOD_(void) SetApplicationShell(nsIApplicationShell * aApplicationShell) = 0;
};
#endif /* nsIShellInstance_h___ */

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

@ -23,15 +23,11 @@ DEFINES = -D_IMPL_NS_WEB
CPPSRCS= \
nsLinkHandler.cpp \
nsShellInstance.cpp \
nsApplicationManager.cpp \
nsWebWidget.cpp \
$(NULL)
CPP_OBJS= \
./$(OBJDIR)/nsLinkHandler.o \
./$(OBJDIR)/nsShellInstance.o \
./$(OBJDIR)/nsApplicationManager.o \
./$(OBJDIR)/nsWebWidget.o \
$(NULL)

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

@ -18,26 +18,16 @@
DEPTH=..\..
IGNORE_MANIFEST=1
DIRS = windows
DEFINES=-D_IMPL_NS_WEB -DWIN32_LEAN_AND_MEAN
MODULE=raptor
EXPORTS = \
nsApplicationManager.h \
$(NULL)
CPPSRCS= \
nsLinkHandler.cpp \
nsShellInstance.cpp \
nsApplicationManager.cpp \
nsWebWidget.cpp \
$(NULL)
CPP_OBJS= \
.\$(OBJDIR)\nsLinkHandler.obj \
.\$(OBJDIR)\nsShellInstance.obj \
.\$(OBJDIR)\nsApplicationManager.obj \
.\$(OBJDIR)\nsWebWidget.obj \
$(NULL)

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

@ -1,160 +0,0 @@
/* -*- Mode: C++; tab-width: 4; 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.
*/
#include "NSApplicationManager.h"
nsHashtable * NSApplicationManager::applications = NULL;
PRMonitor *NSApplicationManager::monitor = NULL;
class ApplicationEntry {
public:
nsIApplicationShell * applicationshell;
nsIShellInstance * shellinstance;
ApplicationEntry(nsIApplicationShell * aApplicationShell,
nsIShellInstance * aShellInstance) {
applicationshell = aApplicationShell;
shellinstance = aShellInstance;
}
~ApplicationEntry() {
}
};
class AppKey: public nsHashKey {
private:
nsIApplicationShell * applicationshell;
public:
AppKey(nsIApplicationShell * aApplicationShell) {
applicationshell = aApplicationShell;
}
PRUint32 HashValue(void) const {
return ((PRUint32) (applicationshell));
}
PRBool Equals(const nsHashKey *aKey) const {
return ((PRBool)(applicationshell == ((AppKey *)aKey)->applicationshell));
}
nsHashKey *Clone(void) const {
return new AppKey(applicationshell);
}
};
nsresult NSApplicationManager::GetShellInstance(nsIApplicationShell * aApplicationShell,
nsIShellInstance **aShellInstance)
{
checkInitialized();
if (aShellInstance == NULL) {
return NS_ERROR_NULL_POINTER;
}
PR_EnterMonitor(monitor);
AppKey key(aApplicationShell);
ApplicationEntry *entry = (ApplicationEntry*) applications->Get(&key);
nsresult res = NS_ERROR_FAILURE;
PR_ExitMonitor(monitor);
if (entry != NULL) {
*aShellInstance = entry->shellinstance;
(*aShellInstance)->AddRef();
res = NS_OK;
}
return res;
}
nsresult NSApplicationManager::checkInitialized()
{
nsresult res = NS_OK;
if (applications == NULL) {
res = Initialize();
}
return res;
}
nsresult NSApplicationManager::Initialize()
{
if (applications == NULL) {
applications = new nsHashtable();
}
if (monitor == NULL) {
monitor = PR_NewMonitor();
}
return NS_OK;
}
nsresult NSApplicationManager::SetShellAssociation(nsIApplicationShell * aApplicationShell,
nsIShellInstance *aShellInstance)
{
checkInitialized();
nsIShellInstance *old = NULL;
GetShellInstance(aApplicationShell, &old);
if (old != NULL) {
old->Release();
return NS_ERROR_FAILURE;
}
PR_EnterMonitor(monitor);
AppKey key(aApplicationShell);
applications->Put(&key, new ApplicationEntry(aApplicationShell, aShellInstance));
PR_ExitMonitor(monitor);
return NS_OK;
}
nsresult NSApplicationManager::DeleteShellAssociation(nsIApplicationShell * aApplicationShell,
nsIShellInstance *aShellInstance)
{
checkInitialized();
nsIShellInstance *old = NULL;
GetShellInstance(aApplicationShell, &old);
nsresult res = NS_ERROR_FACTORY_NOT_REGISTERED;
if (old != NULL) {
if (old == aShellInstance) {
PR_EnterMonitor(monitor);
AppKey key(aApplicationShell);
ApplicationEntry *entry = (ApplicationEntry *) applications->Remove(&key);
delete entry;
PR_ExitMonitor(monitor);
res = NS_OK;
}
old->Release();
}
return res;
}

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

@ -1,56 +0,0 @@
/* -*- Mode: C++; tab-width: 4; 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 __nsApplicationManager_h
#define __nsApplicationManager_h
#include "nscore.h"
#include "plstr.h"
#include "prtypes.h"
#include "prmon.h"
#include "plstr.h"
#include "nsCom.h"
#include "nsweb.h"
#include "nsHashtable.h"
#include "nsIShellInstance.h"
#include "nsIApplicationShell.h"
class NS_WEB NSApplicationManager {
private:
static PRMonitor *monitor;
static nsHashtable * applications;
static nsresult checkInitialized();
public:
static nsresult Initialize();
static nsresult GetShellInstance(nsIApplicationShell * aApplicationShell,
nsIShellInstance **aShellInstance);
static nsresult SetShellAssociation(nsIApplicationShell * aApplicationShell,
nsIShellInstance *aShellInstance);
static nsresult DeleteShellAssociation(nsIApplicationShell * aApplicationShell,
nsIShellInstance *aShellInstance);
};
#endif

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

@ -1,245 +0,0 @@
/* -*- 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.
*/
#include <stdio.h>
#include "nscore.h"
#ifdef NS_WIN32
#include "windows.h"
#endif
#include "nsISupports.h"
#include "nsIShellInstance.h"
#include "nsShellInstance.h"
#include "nsWidgetsCID.h"
#include "nsGfxCIID.h"
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
static NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID);
class nsShellInstanceFactory : public nsIFactory {
public:
nsShellInstanceFactory();
~nsShellInstanceFactory();
NS_DECL_ISUPPORTS
NS_IMETHOD CreateInstance(nsISupports * aOuter,
const nsIID &aIID,
void ** aResult);
NS_IMETHOD LockFactory(PRBool aLock);
};
nsShellInstance::nsShellInstance()
{
}
nsShellInstance::~nsShellInstance()
{
}
NS_IMPL_ADDREF(nsShellInstance)
NS_IMPL_RELEASE(nsShellInstance)
NS_IMPL_QUERY_INTERFACE(nsShellInstance,NS_ISHELLINSTANCE_IID);
nsresult nsShellInstance::Init()
{
nsresult res = NS_OK;
RegisterFactories() ;
return res;
}
nsresult nsShellInstance::Run()
{
#ifdef NS_WIN32
MSG msg;
while (GetMessage(&msg, NULL, 0, 0)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return ((nsresult)msg.wParam);
#else
return NS_OK;
#endif
}
void * nsShellInstance::GetNativeInstance()
{
return mNativeInstance ;
}
void nsShellInstance::SetNativeInstance(void * aNativeInstance)
{
mNativeInstance = aNativeInstance;
return ;
}
nsIApplicationShell * nsShellInstance::GetApplicationShell()
{
return mApplicationShell ;
}
void nsShellInstance::SetApplicationShell(nsIApplicationShell * aApplicationShell)
{
mApplicationShell = aApplicationShell;
return ;
}
// XXX We really need a standard way to enumerate
// a set of libraries and call their self
// registration routines... when that code is
// XP of course.
nsresult nsShellInstance::RegisterFactories()
{
// hardcode names of dll's
#define WIDGET_DLL "raptorwidget.dll"
#ifdef NS_WIN32
#define GFXWIN_DLL "raptorgfxwin.dll"
#else
#define GFXWIN_DLL "raptorgfxunix.dll"
#endif
// register graphics classes
static NS_DEFINE_IID(kCRenderingContextIID, NS_RENDERING_CONTEXT_CID);
static NS_DEFINE_IID(kCDeviceContextIID, NS_DEVICE_CONTEXT_CID);
static NS_DEFINE_IID(kCFontMetricsIID, NS_FONT_METRICS_CID);
static NS_DEFINE_IID(kCImageIID, NS_IMAGE_CID);
NSRepository::RegisterFactory(kCRenderingContextIID, GFXWIN_DLL, PR_FALSE, PR_FALSE);
NSRepository::RegisterFactory(kCDeviceContextIID, GFXWIN_DLL, PR_FALSE, PR_FALSE);
NSRepository::RegisterFactory(kCFontMetricsIID, GFXWIN_DLL, PR_FALSE, PR_FALSE);
NSRepository::RegisterFactory(kCImageIID, GFXWIN_DLL, PR_FALSE, PR_FALSE);
// register widget classes
static NS_DEFINE_IID(kCWindowCID, NS_WINDOW_CID);
static NS_DEFINE_IID(kCChildCID, NS_CHILD_CID);
static NS_DEFINE_IID(kCButtonCID, NS_BUTTON_CID);
static NS_DEFINE_IID(kCCheckButtonCID, NS_CHECKBUTTON_CID);
static NS_DEFINE_IID(kCComboBoxCID, NS_COMBOBOX_CID);
static NS_DEFINE_IID(kCFileWidgetCID, NS_FILEWIDGET_CID);
static NS_DEFINE_IID(kCListBoxCID, NS_LISTBOX_CID);
static NS_DEFINE_IID(kCRadioButtonCID, NS_RADIOBUTTON_CID);
static NS_DEFINE_IID(kCRadioGroupCID, NS_RADIOGROUP_CID);
static NS_DEFINE_IID(kCHorzScrollbarCID, NS_HORZSCROLLBAR_CID);
static NS_DEFINE_IID(kCVertScrollbarCID, NS_VERTSCROLLBAR_CID);
static NS_DEFINE_IID(kCTextAreaCID, NS_TEXTAREA_CID);
static NS_DEFINE_IID(kCTextFieldCID, NS_TEXTFIELD_CID);
NSRepository::RegisterFactory(kCWindowCID, WIDGET_DLL, PR_FALSE, PR_FALSE);
NSRepository::RegisterFactory(kCChildCID, WIDGET_DLL, PR_FALSE, PR_FALSE);
NSRepository::RegisterFactory(kCButtonCID, WIDGET_DLL, PR_FALSE, PR_FALSE);
NSRepository::RegisterFactory(kCCheckButtonCID, WIDGET_DLL, PR_FALSE, PR_FALSE);
NSRepository::RegisterFactory(kCComboBoxCID, WIDGET_DLL, PR_FALSE, PR_FALSE);
NSRepository::RegisterFactory(kCFileWidgetCID, WIDGET_DLL, PR_FALSE, PR_FALSE);
NSRepository::RegisterFactory(kCListBoxCID, WIDGET_DLL, PR_FALSE, PR_FALSE);
NSRepository::RegisterFactory(kCRadioButtonCID, WIDGET_DLL, PR_FALSE, PR_FALSE);
NSRepository::RegisterFactory(kCRadioGroupCID, WIDGET_DLL, PR_FALSE, PR_FALSE);
NSRepository::RegisterFactory(kCHorzScrollbarCID, WIDGET_DLL, PR_FALSE, PR_FALSE);
NSRepository::RegisterFactory(kCVertScrollbarCID, WIDGET_DLL, PR_FALSE, PR_FALSE);
NSRepository::RegisterFactory(kCTextAreaCID, WIDGET_DLL, PR_FALSE, PR_FALSE);
NSRepository::RegisterFactory(kCTextFieldCID, WIDGET_DLL, PR_FALSE, PR_FALSE);
return NS_OK;
}
nsShellInstanceFactory::nsShellInstanceFactory()
{
}
nsShellInstanceFactory::~nsShellInstanceFactory()
{
}
nsresult nsShellInstanceFactory::QueryInterface(REFNSIID aIID, void** aInstancePtr)
{
if (NULL == aInstancePtr) {
return NS_ERROR_NULL_POINTER;
}
if (aIID.Equals(kIFactoryIID)) {
*aInstancePtr = (void*)(nsShellInstanceFactory*)this;
AddRef();
return NS_OK;
}
if (aIID.Equals(kISupportsIID)) {
*aInstancePtr = (void*)(nsISupports*)(nsShellInstanceFactory*)this;
AddRef();
return NS_OK;
}
return NS_NOINTERFACE;
}
NS_IMPL_ADDREF(nsShellInstanceFactory)
NS_IMPL_RELEASE(nsShellInstanceFactory)
nsresult nsShellInstanceFactory::CreateInstance(nsISupports * aOuter,
const nsIID &aIID,
void ** aResult)
{
if (aResult == NULL) {
return NS_ERROR_NULL_POINTER;
}
*aResult = NULL ;
nsISupports * inst = new nsShellInstance() ;
if (inst == NULL) {
return NS_ERROR_OUT_OF_MEMORY;
}
nsresult res = inst->QueryInterface(aIID, aResult);
if (res != NS_OK) {
delete inst ;
}
return res;
}
nsresult nsShellInstanceFactory::LockFactory(PRBool aLock)
{
return NS_OK;
}
// return the proper factory to the caller
extern "C" NS_WEB nsresult NSGetFactory(const nsCID &aClass, nsIFactory **aFactory)
{
if (nsnull == aFactory) {
return NS_ERROR_NULL_POINTER;
}
*aFactory = new nsShellInstanceFactory();
if (nsnull == aFactory) {
return NS_ERROR_OUT_OF_MEMORY;
}
return (*aFactory)->QueryInterface(kIFactoryIID, (void**)aFactory);
}

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

@ -1,60 +0,0 @@
/* -*- 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.
*/
#include <stdio.h>
#include "nsIApplicationShell.h"
#include "nsIFactory.h"
#include "nscore.h"
#include "nsweb.h"
#include "nsCRT.h"
#include "nsIShellInstance.h"
// platform independent native handle to application instance
typedef void * nsNativeApplicationInstance ;
class nsShellInstance : public nsIShellInstance {
public:
nsShellInstance();
~nsShellInstance();
void* operator new(size_t sz) {
void* rv = new char[sz];
nsCRT::zero(rv, sz);
return rv;
}
NS_DECL_ISUPPORTS
NS_IMETHOD Init();
NS_IMETHOD Run();
NS_METHOD RegisterFactories();
NS_METHOD_(void *) GetNativeInstance();
NS_METHOD_(void) SetNativeInstance(void * aNativeInstance);
NS_METHOD_(nsIApplicationShell *) GetApplicationShell();
NS_METHOD_(void) SetApplicationShell(nsIApplicationShell * aApplicationShell);
private:
nsNativeApplicationInstance mNativeInstance ;
nsIApplicationShell * mApplicationShell ;
};

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

@ -1,63 +0,0 @@
#!nmake
#
# 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.
DEPTH=..\..\..
IGNORE_MANIFEST=1
DEFINES=-D_IMPL_NS_WEB -DWIN32_LEAN_AND_MEAN
MODULE=raptor
CPPSRCS= \
winmain.cpp \
$(NULL)
CPP_OBJS= \
.\$(OBJDIR)\winmain.obj \
$(NULL)
LINCS=-I$(XPDIST)\public\xpcom -I$(XPDIST)\public\raptor -I$(XPDIST)\public\dom -I$(XPDIST)\public\js -I..
MAKE_OBJ_TYPE = LIB
LIBRARY_NAME=raptorwebwin_s
LCFLAGS = \
$(LCFLAGS) \
$(DEFINES) \
$(NULL)
# These are the libraries we need to link with to create the dll
LLIBS= \
$(DIST)\lib\xpcom32.lib \
$(DIST)\lib\raptorbase.lib \
$(DIST)\lib\raptorgfx.lib \
$(DIST)\lib\raptorhtml.lib \
$(DIST)\lib\raptorweb.lib \
$(DIST)\lib\img3240.lib \
$(DIST)\lib\util.lib \
$(DIST)\lib\libplc21.lib \
$(DIST)\lib\jsdom.lib \
$(LIBNSPR)
include <$(DEPTH)\config\rules.mak>
install:: $(LIBRARY)
$(MAKE_INSTALL) $(LIBRARY) $(DIST)\lib
clobber::
rm -f $(DIST)\lib\$(LIBNAME).lib

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

@ -1,90 +0,0 @@
/* -*- Mode: C; tab-width: 4; 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 Private 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.
*/
#ifdef WIN32_LEAN_AND_MEAN
#undef WIN32_LEAN_AND_MEAN
#endif
#include <windows.h>
#include "nsRepository.h"
#include "nsShellInstance.h"
#include "nsApplicationManager.h"
#define WEB_DLL "raptorweb.dll"
extern nsIID kIXPCOMApplicationShellCID ;
static NS_DEFINE_IID(kIApplicationShellIID, NS_IAPPLICATIONSHELL_IID);
static NS_DEFINE_IID(kCApplicationShellIID, NS_IAPPLICATIONSHELL_CID);
static NS_DEFINE_IID(kCShellInstanceIID, NS_ISHELLINSTANCE_IID);
int PASCAL WinMain(HANDLE instance, HANDLE prevInstance, LPSTR cmdParam, int nCmdShow)
{
nsresult result = NS_OK ;
nsIShellInstance * pShellInstance ;
nsIApplicationShell * pApplicationShell ;
// Let get a ShellInstance for this Application instance
NSRepository::RegisterFactory(kCShellInstanceIID, WEB_DLL, PR_FALSE, PR_FALSE);
result = NSRepository::CreateInstance(kCShellInstanceIID,
NULL,
kCShellInstanceIID,
(void **) &pShellInstance) ;
if (result != NS_OK)
return result ;
// Let's instantiate the Application's Shell
NS_RegisterApplicationShellFactory() ;
result = NSRepository::CreateInstance(kIXPCOMApplicationShellCID,
NULL,
kIXPCOMApplicationShellCID,
(void **) &pApplicationShell) ;
if (result != NS_OK)
return result ;
// Let the the State know who it's Application Instance is
pShellInstance->SetNativeInstance((nsNativeApplicationInstance) instance);
pShellInstance->SetApplicationShell(pApplicationShell);
// Tell the application manager to store away the association so the
// Application can look up its State
NSApplicationManager::SetShellAssociation(pApplicationShell, pShellInstance);
// Initialize the system
pShellInstance->Init();
pApplicationShell->Init();
// Now, let actually start dispatching events.
result = pApplicationShell->Run();
// We're done, clean up
NSApplicationManager::DeleteShellAssociation(pApplicationShell, pShellInstance);
// book out of here
return result;
}
void main(int argc, char **argv)
{
WinMain(GetModuleHandle(NULL), NULL, 0, SW_SHOW);
}

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

@ -1,394 +0,0 @@
/* -*- Mode: C; tab-width: 4; 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.
*/
//we need openfilename stuff... MMP
#ifdef WIN32_LEAN_AND_MEAN
#undef WIN32_LEAN_AND_MEAN
#endif
#include "windows.h"
#include "prtypes.h"
#include <stdio.h>
#include "resources.h"
#include "nsIImageManager.h"
#include "nsIImageGroup.h"
#include "nsIImageRequest.h"
#include "nsIImageObserver.h"
#include "nsIRenderingContext.h"
#include "nsIImage.h"
#include "nsIWidget.h"
#include "nsGUIEvent.h"
#include "nsRect.h"
#include "nsWidgetsCID.h"
#include "nsGfxCIID.h"
#include "nsApplicationManager.h"
#include "nsImageTest.h"
static NS_DEFINE_IID(kIWidgetIID, NS_IWIDGET_IID);
static NS_DEFINE_IID(kIImageObserverIID, NS_IIMAGEREQUESTOBSERVER_IID);
static char* class1Name = "ImageTest";
static HANDLE gInstance, gPrevInstance;
static nsIImageManager *gImageManager = nsnull;
static nsIImageGroup *gImageGroup = nsnull;
static nsIImageRequest *gImageReq = nsnull;
static HWND gHwnd;
static nsIWidget *gWindow = nsnull;
static nsIImage *gImage = nsnull;
static PRBool gInstalledColorMap = PR_FALSE;
static nsIShellInstance * shellInstance = NULL ;
class MyObserver : public nsIImageRequestObserver {
public:
MyObserver();
~MyObserver();
NS_DECL_ISUPPORTS
virtual void Notify(nsIImageRequest *aImageRequest,
nsIImage *aImage,
nsImageNotification aNotificationType,
PRInt32 aParam1, PRInt32 aParam2,
void *aParam3);
virtual void NotifyError(nsIImageRequest *aImageRequest,
nsImageError aErrorType);
};
MyObserver::MyObserver()
{
}
MyObserver::~MyObserver()
{
}
NS_IMPL_ISUPPORTS(MyObserver, kIImageObserverIID)
void
MyObserver::Notify(nsIImageRequest *aImageRequest,
nsIImage *aImage,
nsImageNotification aNotificationType,
PRInt32 aParam1, PRInt32 aParam2,
void *aParam3)
{
switch (aNotificationType) {
case nsImageNotification_kDimensions:
{
char buffer[40];
sprintf(buffer, "Image:%d x %d", aParam1, aParam2);
::SetWindowText(gHwnd, buffer);
}
break;
case nsImageNotification_kPixmapUpdate:
case nsImageNotification_kImageComplete:
case nsImageNotification_kFrameComplete:
{
if (gImage == nsnull && aImage) {
gImage = aImage;
NS_ADDREF(aImage);
}
if (!gInstalledColorMap && gImage) {
nsColorMap *cmap = gImage->GetColorMap();
if (cmap != nsnull && cmap->NumColors > 0) {
gWindow->SetColorMap(cmap);
}
gInstalledColorMap = PR_TRUE;
}
nsRect *rect = (nsRect *)aParam3;
nsIRenderingContext *drawCtx = gWindow->GetRenderingContext();
if (gImage) {
drawCtx->DrawImage(gImage, 0, 0,
gImage->GetWidth(), gImage->GetHeight());
}
}
break;
}
}
void
MyObserver::NotifyError(nsIImageRequest *aImageRequest,
nsImageError aErrorType)
{
::MessageBox(NULL, "Image loading error!",
class1Name, MB_OK);
}
nsEventStatus PR_CALLBACK
MyHandleEvent(nsGUIEvent *aEvent)
{
nsEventStatus result = nsEventStatus_eConsumeNoDefault;
switch(aEvent->message) {
case NS_PAINT:
{
// paint the background
nsIRenderingContext *drawCtx = ((nsPaintEvent*)aEvent)->renderingContext;
drawCtx->SetColor(aEvent->widget->GetBackgroundColor());
drawCtx->FillRect(*(((nsPaintEvent*)aEvent)->rect));
if (gImage) {
drawCtx->DrawImage(gImage, 0, 0,
gImage->GetWidth(), gImage->GetHeight());
}
return nsEventStatus_eConsumeNoDefault;
}
break;
}
return nsEventStatus_eIgnore;
}
void
MyReleaseImages()
{
if (gImageReq) {
NS_RELEASE(gImageReq);
gImageReq = NULL;
}
if (gImage) {
NS_RELEASE(gImage);
gImage = NULL;
}
gInstalledColorMap = PR_FALSE;
}
void
MyInterrupt()
{
if (gImageGroup) {
gImageGroup->Interrupt();
}
}
#define FILE_URL_PREFIX "file://"
void
MyLoadImage(char *aFileName)
{
char fileURL[256];
char *str;
MyInterrupt();
MyReleaseImages();
if (gImageGroup == NULL) {
nsIRenderingContext *drawCtx = gWindow->GetRenderingContext();
if (NS_NewImageGroup(&gImageGroup) != NS_OK ||
gImageGroup->Init(drawCtx) != NS_OK) {
::MessageBox(NULL, "Couldn't create image group",
class1Name, MB_OK);
NS_RELEASE(drawCtx);
return;
}
NS_RELEASE(drawCtx);
}
strcpy(fileURL, FILE_URL_PREFIX);
strcpy(fileURL + strlen(FILE_URL_PREFIX), aFileName);
str = fileURL;
while ((str = strchr(str, '\\')) != NULL)
*str = '/';
nscolor white;
MyObserver *observer = new MyObserver();
NS_ColorNameToRGB("white", &white);
gImageReq = gImageGroup->GetImage(fileURL,
observer,
white, 0, 0, 0);
if (gImageReq == NULL) {
::MessageBox(NULL, "Couldn't create image request",
class1Name, MB_OK);
}
}
PRBool
OpenFileDialog(char *aBuffer, int32 aBufLen)
{
BOOL result = FALSE;
OPENFILENAME ofn;
// *.js is the standard File Name on the Save/Open Dialog
::strcpy(aBuffer, "*.gif;*.png;*.jpg;*.jpeg");
// fill the OPENFILENAME sruct
ofn.lStructSize = sizeof(OPENFILENAME);
ofn.hwndOwner = gHwnd;
ofn.hInstance = gInstance;
ofn.lpstrFilter = "All Images (*.gif,*.png,*.jpg,*.jpeg)\0*.gif;*png;*.jpg;*.jpeg\0GIF Files (*.gif)\0*.gif\0PNG Files (*.png)\0*.png\0JPEG Files (*.jpg,*.jpeg)\0*.jpg;*.jpeg\0All Files\0*.*\0\0";
ofn.lpstrCustomFilter = NULL;
ofn.nMaxCustFilter = 0;
ofn.nFilterIndex = 1; // the first one in lpstrFilter
ofn.lpstrFile = aBuffer; // contains the file path name on return
ofn.nMaxFile = aBufLen;
ofn.lpstrFileTitle = NULL;
ofn.nMaxFileTitle = 0;
ofn.lpstrInitialDir = NULL; // use default
ofn.lpstrTitle = NULL; // use default
ofn.Flags = OFN_CREATEPROMPT | OFN_HIDEREADONLY | OFN_PATHMUSTEXIST;
ofn.nFileOffset = 0;
ofn.nFileExtension = 0;
ofn.lpstrDefExt = "gif"; // default extension is .js
ofn.lCustData = NULL;
ofn.lpfnHook = NULL;
ofn.lpTemplateName = NULL;
// call the open file dialog or the save file dialog according to aIsOpenDialog
result = ::GetOpenFileName(&ofn);
return (PRBool)result;
}
long PASCAL
WndProc(HWND hWnd, UINT msg, WPARAM param, LPARAM lparam)
{
HMENU hMenu;
switch (msg) {
case WM_COMMAND:
hMenu = GetMenu(hWnd);
switch (LOWORD(param)) {
case TIMER_OPEN:
{
char szFile[256];
if (!OpenFileDialog(szFile, 256))
return 0L;
MyLoadImage(szFile);
break;
}
case TIMER_EXIT:
::DestroyWindow(hWnd);
exit(0);
default:
break;
}
break;
case WM_CREATE:
// Initialize image library
if (NS_NewImageManager(&gImageManager) != NS_OK ||
gImageManager->Init() != NS_OK) {
::MessageBox(NULL, "Can't initialize the image library",
class1Name, MB_OK);
}
gImageManager->SetCacheSize(1024*1024);
break;
case WM_DESTROY:
MyInterrupt();
MyReleaseImages();
if (gImageGroup != nsnull) {
NS_RELEASE(gImageGroup);
}
if (gImageManager != nsnull) {
NS_RELEASE(gImageManager);
}
PostQuitMessage(0);
break;
default:
break;
}
return DefWindowProc(hWnd, msg, param, lparam);
}
static HWND CreateTopLevel(const char* clazz, const char* title,
int aWidth, int aHeight)
{
static NS_DEFINE_IID(kCChildWindowIID, NS_CHILD_CID);
// Create a simple top level window
HWND window = ::CreateWindowEx(WS_EX_CLIENTEDGE,
clazz, title,
WS_OVERLAPPEDWINDOW|WS_CLIPCHILDREN,
CW_USEDEFAULT, CW_USEDEFAULT,
aWidth, aHeight,
HWND_DESKTOP,
NULL,
gInstance,
NULL);
nsRect rect(0, 0, aWidth, aHeight);
nsresult rv = NSRepository::CreateInstance(kCChildWindowIID, NULL, kIWidgetIID, (void**)&gWindow);
if (NS_OK == rv) {
gWindow->Create((nsNativeWindow)window, rect, MyHandleEvent, NULL);
}
::ShowWindow(window, SW_SHOW);
::UpdateWindow(window);
return window;
}
nsresult RunImageTest(nsImageTest * aImageTest)
{
return (shellInstance->Run());
/*
MSG msg;
while (GetMessage(&msg, NULL, 0, 0)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return ((nsresult)msg.wParam);
*/
}
void InitImageTest(nsImageTest * aImageTest)
{
nsresult res = NS_OK;
res = NSApplicationManager::GetShellInstance(aImageTest, &shellInstance) ;
if (res == NS_OK)
gInstance = (HINSTANCE) shellInstance->GetNativeInstance();
// if (!prevInstance) {
WNDCLASS wndClass;
wndClass.style = 0;
wndClass.lpfnWndProc = WndProc;
wndClass.cbClsExtra = 0;
wndClass.cbWndExtra = 0;
wndClass.hInstance = gInstance;
wndClass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wndClass.hCursor = LoadCursor(NULL, IDC_ARROW);
wndClass.hbrBackground = (HBRUSH) GetStockObject(LTGRAY_BRUSH);
wndClass.lpszMenuName = class1Name;
wndClass.lpszClassName = class1Name;
RegisterClass(&wndClass);
// }
// Create our first top level window
HWND gHwnd = CreateTopLevel(class1Name, "Raptor HTML Viewer", 620, 400);
}

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

@ -1,23 +0,0 @@
/* -*- 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.
*/
#include <windows.h>
#include "nsImageTest.h"
void InitImageTest(nsImageTest * aImageTest);
nsresult RunImageTest(nsImageTest * aImageTest);

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

@ -17,7 +17,7 @@
DEPTH=..\..\..
MAKE_OBJ_TYPE = EXE
PROGRAM = .\$(OBJDIR)\nsImageTest.exe
PROGRAM = .\$(OBJDIR)\ImageTest.exe
RESFILE = image.res
MAPFILE = image.map
@ -26,15 +26,13 @@ LINCS=-I$(XPDIST)\public\raptor -I$(XPDIST)\public\xpcom -I..\..\src
LLFLAGS = $(LLFLAGS) /SUBSYSTEM:CONSOLE
OBJS = \
.\$(OBJDIR)\nsImageTest.obj \
.\$(OBJDIR)\ImageTestImpl.obj \
.\$(OBJDIR)\ImageTest.obj \
$(NULL)
LLIBS= \
$(DIST)\lib\raptorbase.lib \
$(DIST)\lib\raptorgfx.lib \
$(DIST)\lib\raptorweb.lib \
$(DIST)\lib\raptorwebwin_s.lib \
$(DIST)\lib\xpcom32.lib \
$(LIBNSPR) \
$(DIST)\lib\libplc21.lib \
@ -48,5 +46,5 @@ install:: $(PROGRAM)
$(MAKE_INSTALL) $(PROGRAM) $(DIST)\bin
clobber::
rm -f $(DIST)\bin\nsImageTest.exe
rm -f $(DIST)\bin\ImageTest.exe

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

@ -1,110 +0,0 @@
/* -*- 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.
*/
#include "nsImageTest.h"
#include "ImageTestImpl.h"
// All Applications must specify this *special* application CID
// to their own unique IID.
nsIID kIXPCOMApplicationShellCID = NS_IIMAGETEST_IID ;
// All Application Must implement this function
nsresult NS_RegisterApplicationShellFactory()
{
nsresult res = NSRepository::RegisterFactory(kIXPCOMApplicationShellCID,
new nsImageTestFactory(),
PR_FALSE) ;
return res;
}
/*
* nsImageTest Definition
*/
nsImageTest::nsImageTest()
{
NS_INIT_REFCNT();
}
nsImageTest::~nsImageTest()
{
}
NS_IMPL_ADDREF(nsImageTest)
NS_IMPL_RELEASE(nsImageTest)
NS_IMPL_QUERY_INTERFACE(nsImageTest,NS_IIMAGETEST_IID);
nsresult nsImageTest::Init()
{
InitImageTest(this);
return NS_OK;
}
nsresult nsImageTest::Run()
{
RunImageTest(this);
return NS_OK;
}
/*
* nsImageTestFactory Definition
*/
nsImageTestFactory::nsImageTestFactory()
{
NS_INIT_REFCNT();
}
nsImageTestFactory::~nsImageTestFactory()
{
}
NS_IMPL_ADDREF(nsImageTestFactory)
NS_IMPL_RELEASE(nsImageTestFactory)
NS_IMPL_QUERY_INTERFACE(nsImageTestFactory,NS_IFACTORY_IID);
nsresult nsImageTestFactory::CreateInstance(nsISupports * aOuter,
const nsIID &aIID,
void ** aResult)
{
if (aResult == NULL) {
return NS_ERROR_NULL_POINTER;
}
*aResult = NULL ;
nsISupports * inst = new nsImageTest() ;
if (inst == NULL) {
return NS_ERROR_OUT_OF_MEMORY;
}
nsresult res = inst->QueryInterface(aIID, aResult);
if (res != NS_OK) {
delete inst ;
}
return res;
}
nsresult nsImageTestFactory::LockFactory(PRBool aLock)
{
return NS_OK;
}

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

@ -1,69 +0,0 @@
/* -*- 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 _nsImageTest_h__
#define _nsImageTest_h__
#include <stdio.h>
#include "nsIApplicationShell.h"
#include "nsIFactory.h"
#include "nsRepository.h"
#include "nsShellInstance.h"
#define NS_IIMAGETEST_IID \
{ 0x5040bd10, 0xdec5, 0x11d1, \
{0x92, 0x44, 0x00, 0x80, 0x5f, 0x8a, 0x7a, 0xb6} }
/*
* ImageTest Class Declaration
*/
class nsImageTest : public nsIApplicationShell {
public:
nsImageTest();
~nsImageTest();
NS_DECL_ISUPPORTS
NS_IMETHOD Init();
NS_IMETHOD Run();
};
/*
* ImageTestFactory Class Declaration
*/
class nsImageTestFactory : public nsIFactory {
public:
nsImageTestFactory();
~nsImageTestFactory();
NS_DECL_ISUPPORTS
NS_IMETHOD CreateInstance(nsISupports * aOuter,
const nsIID &aIID,
void ** aResult);
NS_IMETHOD LockFactory(PRBool aLock);
};
#endif