update nsAppTest for unix to work
git-svn-id: svn://10.0.0.236/trunk@2054 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -33,10 +33,11 @@ EX_LIBS = $(DIST)/lib/libshell_s.a \
|
||||
$(DIST)/lib/libxpcom.a \
|
||||
$(DIST)/lib/libreg.a \
|
||||
$(DIST)/lib/libraptorbase.a \
|
||||
$(DIST)/lib/libraptorgfx.a \
|
||||
$(DIST)/lib/libplc21.a \
|
||||
$(DIST)/lib/libplds21.a \
|
||||
$(DIST)/lib/libnspr21.a \
|
||||
$(DIST)/lib/libshell.a \
|
||||
$(DIST)/lib/libshell.a \
|
||||
$(NULL)
|
||||
|
||||
PROGS = $(addprefix $(OBJDIR)/, $(CPPSRCS:.cpp=))
|
||||
@@ -51,7 +52,7 @@ $(OBJDIR)/%.o: %.cpp
|
||||
|
||||
$(PROGS):$(OBJDIR)/%: $(OBJDIR)/%.o $(EX_LIBS)
|
||||
@$(MAKE_OBJDIR)
|
||||
$(CCC) -o $@ $@.o $(LDFLAGS) $(EX_LIBS) $(OS_LIBS) -lXt -lX11
|
||||
$(CCC) -o $@ $@.o $(LDFLAGS) $(EX_LIBS) $(OS_LIBS) -lXm -lXt -lX11
|
||||
|
||||
export::
|
||||
|
||||
|
||||
@@ -17,7 +17,12 @@
|
||||
*/
|
||||
#include "nscore.h"
|
||||
#include "nsAppTest.h"
|
||||
#include "AppTestImpl.h"
|
||||
#include "nsApplicationManager.h"
|
||||
|
||||
#include "nsString.h"
|
||||
#include "nsFont.h"
|
||||
|
||||
nsEventStatus HandleEventApplication(nsGUIEvent *aEvent);
|
||||
|
||||
// All Applications must specify this *special* application CID
|
||||
// to their own unique IID.
|
||||
@@ -51,21 +56,25 @@ NS_IMPL_ISUPPORTS(nsAppTest,kIAppTestIID);
|
||||
|
||||
nsresult nsAppTest::Init()
|
||||
{
|
||||
#ifdef NS_WIN32
|
||||
InitAppTest(this);
|
||||
#else
|
||||
PRUnichar * p;
|
||||
nsCRT::strlen(p);
|
||||
#endif
|
||||
return NS_OK;
|
||||
|
||||
|
||||
nsresult res = nsApplicationManager::GetShellInstance(this, &mShellInstance) ;
|
||||
|
||||
if (NS_OK != res)
|
||||
return res ;
|
||||
|
||||
nsRect aRect(100,100,540, 380) ;
|
||||
|
||||
mShellInstance->CreateApplicationWindow(aRect, HandleEventApplication);
|
||||
mShellInstance->ShowApplicationWindow(PR_TRUE) ;
|
||||
|
||||
return res ;
|
||||
|
||||
}
|
||||
|
||||
nsresult nsAppTest::Run()
|
||||
{
|
||||
#ifdef NS_WIN32
|
||||
RunAppTest(this);
|
||||
#endif
|
||||
return NS_OK;
|
||||
return (mShellInstance->Run());
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -115,3 +124,61 @@ nsresult nsAppTestFactory::LockFactory(PRBool aLock)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
nsEventStatus PR_CALLBACK HandleEventApplication(nsGUIEvent *aEvent)
|
||||
{
|
||||
nsEventStatus result = nsEventStatus_eConsumeNoDefault;
|
||||
|
||||
switch(aEvent->message) {
|
||||
|
||||
case NS_CREATE:
|
||||
{
|
||||
return nsEventStatus_eConsumeNoDefault;
|
||||
}
|
||||
break ;
|
||||
|
||||
case NS_DESTROY:
|
||||
{
|
||||
//mShellInstance->ExitApplication() ;
|
||||
#ifdef NS_WIN32
|
||||
PostQuitMessage(0);
|
||||
#endif
|
||||
return nsEventStatus_eConsumeNoDefault;
|
||||
}
|
||||
break ;
|
||||
|
||||
case NS_PAINT:
|
||||
{
|
||||
|
||||
// paint the background
|
||||
nsString aString("Hello World!\n");
|
||||
nsIRenderingContext * rndctx = ((nsPaintEvent*)aEvent)->renderingContext;
|
||||
rndctx->SetColor(aEvent->widget->GetBackgroundColor());
|
||||
rndctx->FillRect(*(((nsPaintEvent*)aEvent)->rect));
|
||||
|
||||
nsFont font("Times", NS_FONT_STYLE_NORMAL,
|
||||
NS_FONT_VARIANT_NORMAL,
|
||||
NS_FONT_WEIGHT_BOLD,
|
||||
0,
|
||||
12);
|
||||
rndctx->SetFont(font);
|
||||
|
||||
rndctx->SetColor(NS_RGB(255, 0, 0));
|
||||
rndctx->DrawString(aString, 50, 50, 100);
|
||||
|
||||
|
||||
return nsEventStatus_eConsumeNoDefault;
|
||||
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
return nsEventStatus_eIgnore;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include "nsIApplicationShell.h"
|
||||
#include "nsIShellInstance.h"
|
||||
#include "nsIFactory.h"
|
||||
#include "nsRepository.h"
|
||||
#include "nsShellInstance.h"
|
||||
@@ -43,6 +44,9 @@ public:
|
||||
NS_IMETHOD Init();
|
||||
NS_IMETHOD Run();
|
||||
|
||||
public:
|
||||
nsIShellInstance * mShellInstance;
|
||||
|
||||
};
|
||||
|
||||
/*
|
||||
@@ -63,6 +67,7 @@ public:
|
||||
|
||||
NS_IMETHOD LockFactory(PRBool aLock);
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user