Implement some toplevel windowing functionality

git-svn-id: svn://10.0.0.236/trunk@1118 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
spider
1998-05-05 00:50:35 +00:00
parent 0862eba745
commit f8555ac899
6 changed files with 195 additions and 15 deletions

View File

@@ -16,7 +16,14 @@
* Reserved.
*/
#include "nscore.h"
#ifdef NS_WIN32
#include "windows.h"
#endif
#include "NSApplicationManager.h"
#include "nsString.h"
nsHashtable * NSApplicationManager::applications = NULL;
PRMonitor *NSApplicationManager::monitor = NULL;
@@ -158,3 +165,35 @@ nsresult NSApplicationManager::DeleteShellAssociation(nsIApplicationShell * aApp
return res;
}
nsresult NSApplicationManager::ModalMessage(const nsString &aMessage,
const nsString &aTitle,
nsModalMessageType aModalMessageType)
{
nsresult res = NS_OK ;
#ifdef NS_WIN32
PRInt32 msgtype ;
switch (aModalMessageType)
{
case eModalMessage_ok:
msgtype = MB_OK ;
break ;
case eModalMessage_ok_cancel:
msgtype = MB_OK ;
break ;
default:
msgtype = MB_OK ;
break ;
}
::MessageBox(NULL, (const char *)aMessage.GetUnicode(), (const char *)aTitle.GetUnicode(), msgtype);
#endif
return res ;
}

View File

@@ -26,13 +26,25 @@
#include "prmon.h"
#include "plstr.h"
#include "nsCom.h"
#include "nsweb.h"
#include "nsshell.h"
#include "nsHashtable.h"
#include "nsIShellInstance.h"
#include "nsIApplicationShell.h"
class NS_WEB NSApplicationManager {
/**
* ModalMessage enums
*/
enum nsModalMessageType {
///OK Modal Message
eModalMessage_ok,
///OK/CANCEL Modal Message
eModalMessage_ok_cancel,
};
class NS_SHELL NSApplicationManager {
private:
static PRMonitor *monitor;
static nsHashtable * applications;
@@ -51,6 +63,7 @@ public:
static nsresult DeleteShellAssociation(nsIApplicationShell * aApplicationShell,
nsIShellInstance *aShellInstance);
static nsresult ModalMessage(const nsString &aMessage, const nsString &aTitle, nsModalMessageType aModalMessageType);
};
#endif

View File

@@ -50,6 +50,7 @@ public:
nsShellInstance::nsShellInstance()
{
mApplicationWindow = NULL;
}
nsShellInstance::~nsShellInstance()
@@ -163,6 +164,48 @@ nsresult nsShellInstance::RegisterFactories()
return NS_OK;
}
nsIWidget * nsShellInstance::CreateApplicationWindow(const nsRect &aRect,
EVENT_CALLBACK aHandleEventFunction)
{
static NS_DEFINE_IID(kIWidgetIID, NS_IWIDGET_IID);
static NS_DEFINE_IID(kCWindowCID, NS_WINDOW_CID);
NSRepository::CreateInstance(kCWindowCID,
nsnull,
kIWidgetIID,
(LPVOID*)&(mApplicationWindow));
mApplicationWindow->Create((nsIWidget*)NULL,
aRect,
aHandleEventFunction,
NULL);
return (mApplicationWindow);
}
nsresult nsShellInstance::ShowApplicationWindow(PRBool show)
{
mApplicationWindow->Show(show);
return NS_OK;
}
nsresult nsShellInstance::ExitApplication()
{
#ifdef NS_WIN32
PostQuitMessage(0);
#endif
return NS_OK;
}
void * nsShellInstance::GetApplicationWindowNativeInstance()
{
return (mApplicationWindow->GetNativeData(NS_NATIVE_WINDOW));
}
nsShellInstanceFactory::nsShellInstanceFactory()
{
}

View File

@@ -43,18 +43,27 @@ public:
NS_IMETHOD Run();
NS_METHOD RegisterFactories();
NS_IMETHOD RegisterFactories();
NS_METHOD_(void *) GetNativeInstance();
NS_METHOD_(void) SetNativeInstance(void * aNativeInstance);
NS_IMETHOD_(void *) GetNativeInstance();
NS_IMETHOD_(void) SetNativeInstance(void * aNativeInstance);
NS_METHOD_(nsIApplicationShell *) GetApplicationShell();
NS_METHOD_(void) SetApplicationShell(nsIApplicationShell * aApplicationShell);
NS_IMETHOD_(nsIApplicationShell *) GetApplicationShell();
NS_IMETHOD_(void) SetApplicationShell(nsIApplicationShell * aApplicationShell);
NS_IMETHOD_(nsIWidget *) CreateApplicationWindow(const nsRect &aRect,
EVENT_CALLBACK aHandleEventFunction) ;
NS_IMETHOD ShowApplicationWindow(PRBool show) ;
NS_IMETHOD_(void *) GetApplicationWindowNativeInstance() ;
NS_IMETHOD ExitApplication() ;
private:
nsNativeApplicationInstance mNativeInstance ;
nsIApplicationShell * mApplicationShell ;
nsIWidget * mApplicationWindow ;
};