Implementation of SplashScreenObserver for BeOS

Removed the nsNativeAppSupportBeOS class, as it was not doing anything, and was interfering with the ability for nsAppRunner to check if nsSplashScreenBeOS implemented the IObserver interface, which it now does.

r=cls (seawood@netscape.com)
a=asa (on behalf of drivers) for checin to trunk
This commit is contained in:
arougthopher%lizardland.net 2002-03-05 03:16:23 +00:00
Родитель fd47a2b589
Коммит fd2a869a03
3 изменённых файлов: 128 добавлений и 188 удалений

Двоичные данные
xpfe/bootstrap/apprunner-beos.rsrc

Двоичный файл не отображается.

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

@ -188,7 +188,7 @@ private:
appFileInfo.SetTo(&file) != B_OK ||
appFileInfo.GetSignature(sig) != B_OK)
{
return "application/x-vnd.mozilla.apprunner";
return "application/x-vnd.Mozilla";
}
return sig;
}
@ -317,7 +317,7 @@ PRBool NS_CanRun()
// then rely on nsINativeAppSupport and its use of
// nsISplashScreen will be removed.
//
#if !defined( XP_PC ) && !defined( XP_BEOS ) && !defined(MOZ_WIDGET_GTK)
#if !defined( XP_PC ) && !defined(MOZ_WIDGET_GTK)
nsresult NS_CreateNativeAppSupport( nsINativeAppSupport **aResult )
{
@ -1208,7 +1208,6 @@ static nsresult main1(int argc, char* argv[], nsISupports *nativeApp )
splashScreen->Hide();
}
}
// Release argument object.
NS_IF_RELEASE(nativeApp);
return rv;

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

@ -37,89 +37,45 @@
* ***** END LICENSE BLOCK ***** */
#include "nsNativeAppSupportBase.h"
#include "nsString.h"
#include "nsICmdLineService.h"
#include "nsCOMPtr.h"
#include "nsXPIDLString.h"
#include "nsIComponentManager.h"
#include "nsIServiceManager.h"
#include "nsIAppShellService.h"
#include "nsAppShellCIDs.h"
#include "nsIDOMWindowInternal.h"
#include "nsIObserver.h"
#include <Application.h>
#include <Window.h>
#include <View.h>
#include <StringView.h>
#include <Bitmap.h>
#include <Screen.h>
#include <Font.h>
#include <Resources.h>
#ifdef DEBUG
#define DEBUG_SPLASH 1
#endif
class nsSplashScreenBeOS : public nsISplashScreen {
class nsSplashScreenBeOS : public nsISplashScreen,
public nsIObserver {
public:
nsSplashScreenBeOS();
~nsSplashScreenBeOS();
virtual ~nsSplashScreenBeOS();
NS_DECL_ISUPPORTS
NS_IMETHOD Show();
NS_IMETHOD Hide();
// nsISupports methods
NS_IMETHOD_(nsrefcnt) AddRef() {
mRefCnt++;
return mRefCnt;
}
NS_IMETHOD_(nsrefcnt) Release() {
--mRefCnt;
if ( !mRefCnt ) {
delete this;
return 0;
}
return mRefCnt;
}
NS_IMETHOD QueryInterface( const nsIID &iid, void**p ) {
nsresult rv = NS_OK;
if ( p ) {
*p = 0;
if ( iid.Equals( NS_GET_IID( nsISplashScreen ) ) ) {
nsISplashScreen *result = this;
*p = result;
NS_ADDREF( result );
} else if ( iid.Equals( NS_GET_IID( nsISupports ) ) ) {
nsISupports *result = NS_STATIC_CAST( nsISupports*, this );
*p = result;
NS_ADDREF( result );
} else {
rv = NS_NOINTERFACE;
}
} else {
rv = NS_ERROR_NULL_POINTER;
}
return rv;
}
NS_DECL_NSIOBSERVER
private:
nsresult LoadBitmap();
nsrefcnt mRefCnt;
BWindow *window;
BBitmap *bitmap;
BStringView *textView;
}; // class nsSplashScreenBeOS
class nsNativeAppSupportBeOS : public nsNativeAppSupportBase {
public:
// Overrides of base implementation.
NS_IMETHOD Start( PRBool *aResult );
NS_IMETHOD Stop( PRBool *aResult );
NS_IMETHOD Quit();
private:
nsrefcnt mRefCnt;
}; // nsNativeAppSupportBeOS
nsSplashScreenBeOS::nsSplashScreenBeOS()
: mRefCnt( 0 ) , window( NULL ) , bitmap( NULL ) {
: window( NULL ) , bitmap( NULL ), textView(NULL) {
NS_INIT_REFCNT();
#ifdef DEBUG_SPLASH
puts("nsSplashScreenBeOS::nsSlpashScreenBeOS()");
#endif
@ -132,6 +88,8 @@ nsSplashScreenBeOS::~nsSplashScreenBeOS() {
Hide();
}
NS_IMPL_ISUPPORTS2(nsSplashScreenBeOS, nsISplashScreen, nsIObserver);
NS_IMETHODIMP
nsSplashScreenBeOS::Show() {
#ifdef DEBUG_SPLASH
@ -186,6 +144,39 @@ nsSplashScreenBeOS::Hide() {
return NS_OK;
}
NS_IMETHODIMP
nsSplashScreenBeOS::Observe(nsISupports *aSubject,
const char *aTopic,
const PRUnichar *someData)
{
nsCAutoString statusString;
statusString.AssignWithConversion(someData);
if (textView == NULL) {
BRect textRect = bitmap->Bounds();
// Reduce the view size, and take into account the image frame
textRect.bottom -= 10;
textRect.left += 10;
textRect.right -= 10;
textRect.top = textRect.bottom - 20;
textView = new BStringView(textRect,
"splash text",
statusString.get(),
B_FOLLOW_LEFT | B_FOLLOW_V_CENTER);
textView->SetViewColor(B_TRANSPARENT_COLOR);
textView->SetHighColor(255,255,255,0);
textView->SetLowColor(0,0,0,0);
if (textView != NULL) {
window->AddChild(textView);
}
} else {
if (textView->LockLooper()) {
textView->SetText(statusString.get());
textView->UnlockLooper();
}
}
return NS_OK;
}
nsresult
nsSplashScreenBeOS::LoadBitmap() {
BResources *rsrc = be_app->AppResources();
@ -209,21 +200,6 @@ nsSplashScreenBeOS::LoadBitmap() {
return NS_OK;
}
// Create and return an instance of class nsNativeAppSupportBeOS.
nsresult
NS_CreateNativeAppSupport( nsINativeAppSupport **aResult ) {
if ( aResult ) {
*aResult = new nsNativeAppSupportBeOS();
if ( *aResult ) {
NS_ADDREF( *aResult );
} else {
return NS_ERROR_OUT_OF_MEMORY;
}
} else {
return NS_ERROR_NULL_POINTER;
}
return NS_OK;
}
// Create instance of BeOS splash screen object.
nsresult
@ -232,50 +208,15 @@ NS_CreateSplashScreen( nsISplashScreen **aResult ) {
*aResult = new nsSplashScreenBeOS;
if ( *aResult ) {
NS_ADDREF( *aResult );
return NS_OK;
} else {
return NS_ERROR_OUT_OF_MEMORY;
}
} else {
return NS_ERROR_NULL_POINTER;
}
return NS_OK;
}
NS_IMETHODIMP
nsNativeAppSupportBeOS::Start( PRBool *aResult ) {
NS_ENSURE_ARG( aResult );
nsresult rv = NS_OK;
#ifdef DEBUG_SPLASH
puts("nsNativeAppSupportBeOS::Start()");
#endif
*aResult = PR_TRUE;
return rv;
}
NS_IMETHODIMP
nsNativeAppSupportBeOS::Stop( PRBool *aResult ) {
NS_ENSURE_ARG( aResult );
nsresult rv = NS_OK;
#ifdef DEBUG_SPLASH
puts("nsNativeAppSupportBeOS::Stop()");
#endif
*aResult = PR_TRUE;
return rv;
}
NS_IMETHODIMP
nsNativeAppSupportBeOS::Quit() {
#ifdef DEBUG_SPLASH
puts("nsNativeAppSupportBeOS::Quit()");
#endif
return NS_OK;
}
PRBool NS_CanRun()
{