Back to index

lightning-sunbird  0.9+nobinonly
nsNativeAppSupportBeOS.cpp
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
00002 /* ***** BEGIN LICENSE BLOCK *****
00003  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00004  *
00005  * The contents of this file are subject to the Mozilla Public License Version
00006  * 1.1 (the "License"); you may not use this file except in compliance with
00007  * the License. You may obtain a copy of the License at
00008  * http://www.mozilla.org/MPL/
00009  *
00010  * Software distributed under the License is distributed on an "AS IS" basis,
00011  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00012  * for the specific language governing rights and limitations under the
00013  * License.
00014  *
00015  * The Original Code is Mozilla Communicator client code.
00016  *
00017  * The Initial Developer of the Original Code is
00018  * Netscape Communications Corporation.
00019  * Portions created by the Initial Developer are Copyright (C) 1998
00020  * the Initial Developer. All Rights Reserved.
00021  *
00022  * Contributor(s):
00023  *   Takashi Toyoshima <toyoshim@be-in.org>
00024  *   Fredrik Holmqvist <thesuckiestemail@yahoo.se>
00025  *
00026  * Alternatively, the contents of this file may be used under the terms of
00027  * either of the GNU General Public License Version 2 or later (the "GPL"),
00028  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00029  * in which case the provisions of the GPL or the LGPL are applicable instead
00030  * of those above. If you wish to allow use of your version of this file only
00031  * under the terms of either the GPL or the LGPL, and not to allow others to
00032  * use your version of this file under the terms of the MPL, indicate your
00033  * decision by deleting the provisions above and replace them with the notice
00034  * and other provisions required by the GPL or the LGPL. If you do not delete
00035  * the provisions above, a recipient may use your version of this file under
00036  * the terms of any one of the MPL, the GPL or the LGPL.
00037  *
00038  * ***** END LICENSE BLOCK ***** */
00039 
00040 //This define requires DebugConsole (see BeBits.com) to be installed
00041 //#define DC_PROGRAMNAME "seamonkey-bin"
00042 
00043 #include "nsStringSupport.h"
00044 #include "nsNativeAppSupportBase.h"
00045 #include "nsIObserver.h"
00046 
00047 #include "nsICmdLineService.h"
00048 #include "nsIBrowserDOMWindow.h"
00049 #include "nsIScriptGlobalObject.h"
00050 #include "nsIDOMWindowInternal.h"
00051 #include "nsIDOMChromeWindow.h"
00052 #include "nsIWindowMediator.h"
00053 #include "nsIURI.h"
00054 #include "nsIURIFixup.h"
00055 #include "nsCDefaultURIFixup.h"
00056 #include "nsIProxyObjectManager.h"
00057 #include "nsXPFEComponentsCID.h"
00058 #include "nsIAppStartup.h"
00059 #include "nsIComponentManager.h"
00060 #include "nsIAppShellService.h"
00061 #include "nsVoidArray.h"
00062 #include "nsIBaseWindow.h"
00063 #include "nsIWidget.h"
00064 #include "nsIDocShell.h"
00065 
00066 #include <Application.h>
00067 #include <AppFileInfo.h>
00068 #include <Window.h>
00069 #include <View.h>
00070 #include <StringView.h>
00071 #include <Bitmap.h>
00072 #include <Screen.h>
00073 #include <Font.h>
00074 #include <Resources.h>
00075 #include <Path.h>
00076 #include <stdlib.h>
00077 
00078 #ifdef DC_PROGRAMNAME
00079 # include <DebugConsole.h>
00080 #endif
00081 
00082 #ifdef DEBUG
00083 #define DEBUG_SPLASH 1
00084 #endif
00085 
00086 static nsresult
00087 GetMostRecentWindow(const PRUnichar* aType, nsIDOMWindowInternal** aWindow)
00088 {
00089        nsresult rv;
00090        nsCOMPtr<nsIWindowMediator> med(do_GetService( NS_WINDOWMEDIATOR_CONTRACTID, &rv));
00091        if (NS_FAILED(rv))
00092        {
00093 #ifdef DC_PROGRAMNAME
00094               TRACE("no med");
00095 #endif
00096               return rv;
00097        }
00098 
00099        if (med)
00100               return med->GetMostRecentWindow(aType, aWindow);
00101        return NS_ERROR_FAILURE;
00102 }
00103 
00104 // When URI is opened from click or drop,
00105 // user expects to see it in current wokspace and activated
00106 static nsresult
00107 ActivateWindow(nsIDOMWindowInternal* aWindow)
00108 {
00109        nsCOMPtr<nsIScriptGlobalObject> window(do_QueryInterface(aWindow));
00110        NS_ENSURE_TRUE(window, NS_ERROR_FAILURE);
00111 
00112        nsCOMPtr<nsIBaseWindow> baseWindow(do_QueryInterface(window->GetDocShell()));
00113        NS_ENSURE_TRUE(baseWindow, NS_ERROR_FAILURE);
00114        nsCOMPtr<nsIWidget> mainWidget;
00115        baseWindow->GetMainWidget(getter_AddRefs(mainWidget));
00116        NS_ENSURE_TRUE(mainWidget, NS_ERROR_FAILURE);
00117        BWindow *bwindow = (BWindow *)(mainWidget->GetNativeData(NS_NATIVE_WINDOW));
00118        if (bwindow)
00119        {
00120               bwindow->SetWorkspaces(B_CURRENT_WORKSPACE);
00121               bwindow->Activate(true);
00122        }
00123        return NS_OK;
00124 }
00125 // End static helpers
00126 
00127 class nsNativeAppSupportBeOS : public nsNativeAppSupportBase,  public nsIObserver
00128 {
00129 public:
00130        nsNativeAppSupportBeOS();
00131        ~nsNativeAppSupportBeOS();
00132        NS_DECL_ISUPPORTS
00133        NS_DECL_NSINATIVEAPPSUPPORT
00134        NS_DECL_NSIOBSERVER
00135        static void HandleCommandLine( int32 argc, char **argv );
00136     
00137 private:
00138        static nsresult OpenBrowserWindow(const char *args);
00139        nsresult LoadBitmap();
00140        BWindow *window;
00141        BBitmap *bitmap;
00142        BStringView *textView;
00143 }; // nsNativeAppSupportBeOS
00144 
00145 class nsBeOSApp : public BApplication
00146 {
00147 public:
00148        nsBeOSApp(sem_id sem) : BApplication(GetAppSig()), init(sem),
00149                                                  appEnabled(false), mMessage(0)
00150        {}
00151 
00152        ~nsBeOSApp()
00153        {
00154               mMessage.Clear();
00155        }
00156 
00157        void ReadyToRun()
00158        {
00159               release_sem(init);
00160        }
00161 
00162        static int32 Main(void *args)
00163        {
00164               nsBeOSApp *app = new nsBeOSApp((sem_id)args);
00165               if (app == NULL)
00166                      return B_ERROR;
00167               return app->Run();
00168        }
00169 
00170        void ArgvReceived(int32 argc, char **argv)
00171        {
00172               if (!IsLaunching()) 
00173                      nsNativeAppSupportBeOS::HandleCommandLine(argc, argv);
00174        }
00175 
00176        void RefsReceived(BMessage *msg)
00177        {
00178               // If UI is started, call ArgReceived, else store for future usage.
00179               // appEnabled is set to true after ::HideSplash() was called
00180               if (!appEnabled)
00181               {
00182 #ifdef DC_PROGRAMNAME
00183                      TRACE("Refs at Launch!");
00184 #endif
00185                      mMessage.InsertElementAt((void *)new BMessage(*msg), mMessage.Count());
00186                      return;
00187               }
00188 
00189               entry_ref er;
00190               BPath path;   
00191               for (uint32 i = 0; msg->FindRef("refs", i, &er) == B_OK; i++)
00192               {
00193                      int Argc = 2;
00194                      char **Argv = new char*[ 3 ];
00195                      BEntry entry(&er, true);
00196                      BEntry fentry(GetAppFile(), false);
00197                      entry.GetPath(&path);
00198                      Argv[0] = strdup( GetAppFile() ? GetAppFile() : "" );
00199                      Argv[1] = strdup( path.Path() ? path.Path() : "" );
00200                      // Safety measure
00201                      Argv[2] = 0;
00202                      ArgvReceived(Argc, Argv);
00203                      Argc = 0;
00204                      delete [] Argv;
00205                      Argv = NULL;
00206               } 
00207        }
00208 
00209        void MessageReceived(BMessage *msg)
00210        {
00211               if (msg->what == 'enbl' && !appEnabled)
00212               {
00213 #ifdef DC_PROGRAMNAME
00214                      TRACE("mMessage!");
00215 #endif
00216                      appEnabled = true;
00217               }
00218               
00219               if (appEnabled && mMessage.Count())
00220               {
00221                      for (int i = 0; i < mMessage.Count(); i++)
00222                      {
00223                             be_app_messenger.SendMessage((BMessage *)mMessage.SafeElementAt(i));
00224                      }
00225                      mMessage.Clear();
00226               }
00227               
00228               if (msg->what == B_SIMPLE_DATA && appEnabled)
00229               {
00230                      RefsReceived(msg);
00231               }
00232               BApplication::MessageReceived(msg);
00233        }
00234 
00235        char *GetAppSig()
00236        {
00237               image_info info;
00238               int32 cookie = 0;
00239               BFile file;
00240               BAppFileInfo appFileInfo;
00241               static char sig[B_MIME_TYPE_LENGTH];
00242 
00243               sig[0] = 0;
00244               if (get_next_image_info(0, &cookie, &info) == B_OK &&
00245                      file.SetTo(info.name, B_READ_ONLY) == B_OK &&
00246                      appFileInfo.SetTo(&file) == B_OK &&
00247                      appFileInfo.GetSignature(sig) == B_OK)
00248               {
00249                      return sig;
00250               }
00251               return "application/x-vnd.Mozilla-SeaMonkey";
00252        }
00253 
00254        char *GetAppFile()
00255        {
00256               image_info info;
00257               int32 cookie = 0;
00258               if (get_next_image_info(0, &cookie, &info) == B_OK && strlen(info.name) > 0)
00259                      return info.name;
00260               return "./seamonkey-bin";
00261        }
00262 
00263 private:
00264        sem_id init;
00265        bool appEnabled;
00266        nsVoidArray mMessage;
00267 
00268 }; //class nsBeOSApp
00269 
00270 // Create and return an instance of class nsNativeAppSupportBeOS.
00271 nsresult
00272 NS_CreateNativeAppSupport(nsINativeAppSupport **aResult) 
00273 {
00274     if(!aResult) 
00275         return NS_ERROR_NULL_POINTER;
00276     
00277     nsNativeAppSupportBeOS *pNative = new nsNativeAppSupportBeOS();
00278     if (!pNative)
00279         return NS_ERROR_OUT_OF_MEMORY;
00280 
00281     *aResult = pNative;
00282     NS_ADDREF(*aResult);
00283     return NS_OK;
00284 }
00285 
00286 nsNativeAppSupportBeOS::nsNativeAppSupportBeOS()
00287        : window(NULL) , bitmap(NULL), textView(NULL)
00288 {}
00289 
00290 nsNativeAppSupportBeOS::~nsNativeAppSupportBeOS()
00291 {
00292        if (window != NULL)
00293               HideSplashScreen();
00294 }
00295 
00296 NS_IMPL_ISUPPORTS2(nsNativeAppSupportBeOS, nsINativeAppSupport, nsIObserver)
00297 
00298 void nsNativeAppSupportBeOS::HandleCommandLine(int32 argc, char **argv)
00299 {
00300        nsresult rv;
00301        nsCOMPtr<nsICmdLineService> cmdLineArgs;// = (do_GetService(NS_COMMANDLINESERVICE_CONTRACTID, &rv));
00302        nsCOMPtr<nsIComponentManager> compMgr;
00303        NS_GetComponentManager(getter_AddRefs(compMgr));
00304        rv = compMgr->CreateInstanceByContractID(
00305                                    NS_COMMANDLINESERVICE_CONTRACTID,
00306                                    nsnull, NS_GET_IID(nsICmdLineService),
00307                                    (void **)getter_AddRefs(cmdLineArgs));
00308        
00309        rv = cmdLineArgs->Initialize(argc, argv);
00310        if (NS_FAILED(rv)) return;
00311 
00312        nsCOMPtr<nsIAppStartup> appStartup (do_GetService(NS_APPSTARTUP_CONTRACTID, &rv));
00313        if (NS_FAILED(rv)) return;
00314        nsCOMPtr<nsIAppStartup> appStartupProxy;
00315        rv = NS_GetProxyForObject(NS_UI_THREAD_EVENTQ, NS_GET_IID(nsIAppStartup), 
00316                                                         appStartup, PROXY_ASYNC | PROXY_ALWAYS,
00317                                                         getter_AddRefs(appStartupProxy));
00318        nsCOMPtr<nsINativeAppSupport> nativeApp;
00319        rv = appStartup->GetNativeAppSupport(getter_AddRefs(nativeApp));
00320        if (NS_FAILED(rv))
00321        {
00322 #ifdef DC_PROGRAMNAME
00323               TRACE("No GetNativeAppSupport");
00324 #endif
00325               return;
00326        }
00327 
00328        rv = appStartup->Ensure1Window(cmdLineArgs);
00329        if (NS_FAILED(rv))
00330        {
00331 #ifdef DC_PROGRAMNAME
00332               TRACE("No Ensure1Window");
00333 #endif
00334               return;
00335        }
00336        
00337        // first see if there is a url
00338        nsXPIDLCString urlToLoad;
00339        rv = cmdLineArgs->GetURLToLoad(getter_Copies(urlToLoad));
00340        if (NS_SUCCEEDED(rv) && !urlToLoad.IsEmpty())
00341        {
00342               nsCOMPtr<nsICmdLineHandler> handler(
00343                      do_GetService("@mozilla.org/commandlinehandler/general-startup;1?type=browser"));
00344 
00345               nsXPIDLCString chromeUrlForTask;
00346               rv = handler->GetChromeUrlForTask(getter_Copies(chromeUrlForTask));
00347 
00348               if (NS_SUCCEEDED(rv))
00349                      rv = OpenBrowserWindow(urlToLoad.get());
00350        }
00351 }
00352 
00353 // Open the argument URL in the most recently used Navigator window.
00354 nsresult
00355 nsNativeAppSupportBeOS::OpenBrowserWindow(const char *args)
00356 {
00357        nsresult rv;
00358 
00359        // Get most recently used Nav window.
00360        nsCOMPtr<nsIDOMWindowInternal> navWin;
00361        rv = GetMostRecentWindow(NS_LITERAL_STRING("navigator:browser").get(), getter_AddRefs(navWin ));
00362 
00363        // If caller requires a new window, then don't use an existing one.
00364        if (NS_FAILED(rv) || !navWin)
00365        {
00366 #ifdef DC_PROGRAMNAME
00367               TRACE("!navWin");
00368 #endif
00369               return NS_ERROR_FAILURE;
00370        }
00371 
00372        nsCOMPtr<nsIDOMChromeWindow> chromeWin(do_QueryInterface(navWin, &rv));
00373        if (NS_FAILED(rv) || !chromeWin)
00374        {
00375 #ifdef DC_PROGRAMNAME
00376               TRACE("!chromeWin");
00377 #endif
00378               return NS_ERROR_FAILURE;
00379        }
00380 
00381        nsCOMPtr<nsIBrowserDOMWindow> bwin;
00382        rv = chromeWin->GetBrowserDOMWindow(getter_AddRefs(bwin));
00383        if (NS_FAILED(rv) || !bwin)
00384        {
00385 #ifdef DC_PROGRAMNAME
00386               TRACE("!bwin");
00387 #endif
00388               return NS_ERROR_FAILURE;
00389        }
00390 
00391        nsCOMPtr<nsIURIFixup> fixup(do_GetService(NS_URIFIXUP_CONTRACTID, &rv));
00392        if (NS_FAILED(rv) || !fixup)
00393        {
00394 #ifdef DC_PROGRAMNAME
00395               TRACE("!fixup");
00396 #endif
00397               return NS_ERROR_FAILURE;
00398        }
00399 
00400        nsCOMPtr<nsIURI> uri;
00401        rv = fixup->CreateFixupURI(nsDependentCString(args),
00402                                                  nsIURIFixup::FIXUP_FLAG_NONE,
00403                                                  getter_AddRefs(uri));
00404        if (NS_FAILED(rv) || !uri)
00405        {
00406 #ifdef DC_PROGRAMNAME
00407               TRACE("!uri");
00408 #endif
00409               return NS_ERROR_FAILURE;
00410        }
00411 
00412 #ifdef DC_PROGRAMNAME
00413        TRACE("OpenURI! %s", uri.get());
00414 #endif
00415        nsCOMPtr<nsIBrowserDOMWindow> bwinProxy;
00416        rv = NS_GetProxyForObject(
00417                      NS_UI_THREAD_EVENTQ,
00418                      NS_GET_IID(nsIBrowserDOMWindow),
00419                      bwin, 
00420                      PROXY_ASYNC | PROXY_ALWAYS, 
00421                      getter_AddRefs(bwinProxy));
00422        
00423        if (NS_FAILED(rv))
00424        {
00425               printf("!bwinProxy");
00426               return rv;
00427        }
00428 
00429        nsCOMPtr<nsIDOMWindow> resWin;
00430        rv =  bwinProxy->OpenURI( uri, nsnull, nsIBrowserDOMWindow::OPEN_DEFAULTWINDOW, nsIBrowserDOMWindow::OPEN_EXTERNAL, getter_AddRefs(resWin) );
00431        // rv failure may be just 404, so still activating navWin exists
00432        ActivateWindow(navWin);
00433        return rv;
00434 }
00435 
00436 NS_IMETHODIMP nsNativeAppSupportBeOS::Start(PRBool *aResult) 
00437 {
00438        NS_ENSURE_ARG(aResult);
00439        NS_ENSURE_TRUE(be_app == NULL, NS_ERROR_NOT_INITIALIZED);
00440        
00441        sem_id initsem = create_sem(0, "Mozilla BApplication init");
00442        if (initsem < B_OK)
00443               return NS_ERROR_FAILURE;
00444        thread_id tid = spawn_thread(nsBeOSApp::Main, "Mozilla BApplication", B_NORMAL_PRIORITY, (void *)initsem);
00445        *aResult = PR_TRUE;
00446        if (tid < B_OK || B_OK != resume_thread(tid))
00447               *aResult = PR_FALSE;
00448 
00449        if (B_OK != acquire_sem(initsem))
00450               *aResult = PR_FALSE;
00451 
00452        if (B_OK != delete_sem(initsem))
00453               *aResult = PR_FALSE;
00454        return *aResult == PR_TRUE ? NS_OK : NS_ERROR_FAILURE;
00455 }
00456 
00457 NS_IMETHODIMP nsNativeAppSupportBeOS::Stop(PRBool *aResult) 
00458 {
00459        NS_ENSURE_ARG(aResult);
00460        NS_ENSURE_TRUE(be_app, NS_ERROR_NOT_INITIALIZED);
00461        // Do we need it here?
00462        //Quit();
00463        *aResult = PR_TRUE;
00464        return NS_OK;
00465 }
00466 
00467 NS_IMETHODIMP nsNativeAppSupportBeOS::Quit() 
00468 {
00469        be_app_messenger.SendMessage(B_QUIT_REQUESTED);
00470        return NS_OK;
00471 }
00472 
00473 NS_IMETHODIMP nsNativeAppSupportBeOS::EnsureProfile(nsICmdLineService* args)
00474 {
00475        // TODO: Needs some code for -turbo mode
00476        return NS_OK;
00477 }
00478 
00479 NS_IMETHODIMP nsNativeAppSupportBeOS::ReOpen()
00480 {
00481        return NS_ERROR_NOT_IMPLEMENTED;
00482 }
00483 
00484 NS_IMETHODIMP nsNativeAppSupportBeOS::OnLastWindowClosing()
00485 {
00486        return NS_OK;
00487 }
00488 
00489 NS_IMETHODIMP nsNativeAppSupportBeOS::GetIsServerMode(PRBool *aIsServerMode)
00490 {
00491        aIsServerMode = PR_FALSE;
00492        return NS_OK;
00493 }
00494 
00495 NS_IMETHODIMP nsNativeAppSupportBeOS::SetIsServerMode(PRBool aIsServerMode)
00496 {
00497        return NS_ERROR_NOT_IMPLEMENTED;
00498 }
00499 
00500 NS_IMETHODIMP nsNativeAppSupportBeOS::StartServerMode()
00501 {
00502        return NS_ERROR_NOT_IMPLEMENTED;
00503 }
00504 
00505 NS_IMETHODIMP nsNativeAppSupportBeOS::SetShouldShowUI(PRBool aShouldShowUI)
00506 {
00507        return NS_ERROR_NOT_IMPLEMENTED;
00508 }
00509 
00510 NS_IMETHODIMP nsNativeAppSupportBeOS::GetShouldShowUI(PRBool *aShouldShowUI)
00511 {
00512        *aShouldShowUI = PR_TRUE;
00513        return NS_OK;
00514 }
00515 
00516 NS_IMETHODIMP nsNativeAppSupportBeOS::ShowSplashScreen()
00517 {
00518 #ifdef DEBUG_SPLASH
00519        puts("nsNativeAppSupportBeOS::ShowSplashScreen()");
00520 #endif
00521        if (NULL == bitmap && NS_OK != LoadBitmap())
00522               return NS_ERROR_FAILURE;
00523 
00524        // Get the center position.
00525        BScreen scr;
00526        BRect scrRect = scr.Frame();
00527        BRect bmpRect = bitmap->Bounds();
00528        float winX = (scrRect.right - bmpRect.right) / 2;
00529        float winY = (scrRect.bottom - bmpRect.bottom) / 2;
00530        BRect winRect(winX, winY, winX + bmpRect.right, winY + bmpRect.bottom);
00531 #ifdef DEBUG_SPLASH
00532        printf("SplashRect (%f, %f) - (%f, %f)\n", winRect.left, winRect.top,
00533                                                                                     winRect.right, winRect.bottom);
00534 #endif
00535        if (NULL == window) 
00536        {
00537               window = new BWindow(winRect, "mozilla splash",
00538                                                  B_NO_BORDER_WINDOW_LOOK, B_MODAL_APP_WINDOW_FEEL, 0);
00539               if (NULL == window)
00540                      return NS_ERROR_FAILURE;
00541               BView *view = new BView(bmpRect, "splash view", B_FOLLOW_ALL_SIDES, B_WILL_DRAW);
00542               if (NULL != view)
00543               {
00544                      window->AddChild(view);
00545                      view->SetViewBitmap(bitmap);
00546               }
00547               window->Show();
00548        }
00549        return NS_OK;
00550 }
00551 
00552 NS_IMETHODIMP nsNativeAppSupportBeOS::HideSplashScreen()
00553 {
00554 #ifdef DEBUG_SPLASH
00555        puts("nsNativeAppSupportBeOS::HideSplashScreen()");
00556 #endif
00557        if (NULL != window)
00558        {
00559               if (window->Lock())
00560                      window->Quit();
00561               window = NULL;
00562        }
00563        if (NULL != bitmap)
00564        {
00565               delete bitmap;
00566               bitmap = NULL;
00567        }
00568        // Notification, now we are able to process scheduled RefsReceived().
00569        if (be_app)
00570               be_app_messenger.SendMessage('enbl');
00571        return NS_OK;
00572 }
00573 
00574 NS_IMETHODIMP nsNativeAppSupportBeOS::Observe(nsISupports *aSubject,
00575                                                                                     const char *aTopic,
00576                                                                                     const PRUnichar *someData)
00577 {
00578        if (!bitmap)
00579               return NS_OK;
00580        nsCAutoString statusString;
00581        statusString.AssignWithConversion(someData);
00582        if (textView != NULL)
00583        {
00584               if (textView->LockLooper())
00585               {
00586                      textView->SetText(statusString.get());
00587                      textView->UnlockLooper();
00588               }
00589               return NS_OK;
00590        }
00591        BRect textRect = bitmap->Bounds();
00592        textView = new BStringView(textRect, "splash text",
00593                                                         statusString.get(),
00594                                                         B_FOLLOW_LEFT | B_FOLLOW_V_CENTER);
00595 
00596        if (!textView)
00597               return NS_OK;
00598 
00599        // Reduce the view size, and take into account the image frame
00600        textRect.bottom -= 10;
00601        textRect.left += 10;
00602        textRect.right -= 10; 
00603        textRect.top = textRect.bottom - 20;
00604        textView->SetViewColor(B_TRANSPARENT_COLOR);
00605        textView->SetHighColor(255,255,255,0);
00606        textView->SetLowColor(0,0,0,0);
00607        window->AddChild(textView);
00608        return NS_OK;
00609 }
00610 
00611 nsresult nsNativeAppSupportBeOS::LoadBitmap()
00612 {
00613        BResources *rsrc = be_app->AppResources();
00614        if (NULL == rsrc)
00615               return NS_ERROR_FAILURE;
00616        size_t length;
00617        const void *data = rsrc->LoadResource('BBMP', "MOZILLA:SPLASH", &length);
00618        if (NULL == data)
00619               return NS_ERROR_FAILURE;
00620        BMessage msg;
00621        if (B_OK != msg.Unflatten((const char *) data))
00622               return NS_ERROR_FAILURE;
00623        BBitmap *bmp = new BBitmap(&msg);
00624        if (NULL == bmp)
00625               return NS_ERROR_FAILURE;
00626        bitmap = new BBitmap(bmp, true);
00627        if (NULL == bitmap)
00628        {
00629               delete bmp;
00630               return NS_ERROR_FAILURE;
00631        }
00632        return NS_OK;
00633 }