TRootApplication.cxx

Go to the documentation of this file.
00001 // @(#)root/gui:$Id: TRootApplication.cxx 23115 2008-04-10 13:35:37Z rdm $
00002 // Author: Fons Rademakers   15/01/98
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
00006  * All rights reserved.                                                  *
00007  *                                                                       *
00008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00010  *************************************************************************/
00011 
00012 //////////////////////////////////////////////////////////////////////////
00013 //                                                                      //
00014 // TRootApplication                                                     //
00015 //                                                                      //
00016 // This class create the ROOT native GUI version of the ROOT            //
00017 // application environment. This in contrast to the Win32 version.      //
00018 // Once the native widgets work on Win32 this class can be folded into  //
00019 // the TApplication class (since all graphic will go via TVirtualX).    //
00020 //                                                                      //
00021 //////////////////////////////////////////////////////////////////////////
00022 
00023 #include "TRootApplication.h"
00024 #include "TSystem.h"
00025 #include "TString.h"
00026 #include "TGClient.h"
00027 #include "TVirtualX.h"
00028 
00029 ClassImp(TRootApplication)
00030 
00031 //______________________________________________________________________________
00032 TRootApplication::TRootApplication(const char *appClassName,
00033                                    Int_t *argc, char **argv)
00034 {
00035    // Create ROOT application environment.
00036    
00037    fApplicationName = appClassName;
00038    fDisplay         = 0;
00039 
00040    GetOptions(argc, argv);
00041 
00042    if (!fDisplay)
00043       // Set DISPLAY based on utmp (only if DISPLAY is not yet set).
00044       gSystem->SetDisplay();
00045 
00046    fClient = new TGClient(fDisplay);
00047 
00048    if (fClient->IsZombie()) {
00049       delete fClient;
00050       fClient = 0;
00051    }
00052 }
00053 
00054 //______________________________________________________________________________
00055 TRootApplication::~TRootApplication()
00056 {
00057    // Delete ROOT application environment.
00058 
00059    delete [] fDisplay;
00060    delete fClient;
00061 }
00062 
00063 //______________________________________________________________________________
00064 Bool_t TRootApplication::IsCmdThread()
00065 {
00066    // By default (for UNIX) ROOT is a single thread application
00067    // For win32gdk returns kTRUE if it's called from inside of server/cmd thread
00068 
00069    return gVirtualX ? gVirtualX->IsCmdThread() : kTRUE;
00070 }
00071 
00072 //______________________________________________________________________________
00073 void TRootApplication::GetOptions(Int_t *argc, char **argv)
00074 {
00075    // Handle command line arguments. Arguments handled are removed from the
00076    // argument array. Currently only option "-display xserver" is considered.
00077 
00078    if (!argc) return;
00079 
00080    int i, j;
00081    for (i = 0; i < *argc; i++) {
00082       if (!strcmp(argv[i], "-display")) {
00083          if (argv[i+1] && strlen(argv[i+1]) && argv[i+1][0] != '-') {
00084             fDisplay  = StrDup(argv[i+1]);
00085             argv[i]   = 0;
00086             argv[i+1] = 0;
00087             i++;
00088          }
00089       }
00090    }
00091 
00092    j = 0;
00093    for (i = 0; i < *argc; i++) {
00094       if (argv[i]) {
00095          argv[j] = argv[i];
00096          j++;
00097       }
00098    }
00099 
00100    *argc = j;
00101 }
00102 

Generated on Tue Jul 5 14:22:06 2011 for ROOT_528-00b_version by  doxygen 1.5.1