Logo ROOT  
Reference Guide
TRootApplication.cxx
Go to the documentation of this file.
1// @(#)root/gui:$Id$
2// Author: Fons Rademakers 15/01/98
3
4/*************************************************************************
5 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
11
12//////////////////////////////////////////////////////////////////////////
13// //
14// TRootApplication //
15// //
16// This class create the ROOT native GUI version of the ROOT //
17// application environment. This in contrast to the Win32 version. //
18// Once the native widgets work on Win32 this class can be folded into //
19// the TApplication class (since all graphic will go via TVirtualX). //
20// //
21//////////////////////////////////////////////////////////////////////////
22
23#include "TRootApplication.h"
24#include "TSystem.h"
25#include "TString.h"
26#include "TGClient.h"
27#include "TVirtualX.h"
28
30
31////////////////////////////////////////////////////////////////////////////////
32/// Create ROOT application environment.
33
34TRootApplication::TRootApplication(const char *appClassName,
35 Int_t *argc, char **argv)
36{
37 fApplicationName = appClassName;
38 fDisplay = 0;
39
40 GetOptions(argc, argv);
41
42 if (!fDisplay)
43 // Set DISPLAY based on utmp (only if DISPLAY is not yet set).
45
47
48 if (fClient->IsZombie()) {
49 delete fClient;
50 fClient = 0;
51 }
52}
53
54////////////////////////////////////////////////////////////////////////////////
55/// Delete ROOT application environment.
56
58{
59 delete [] fDisplay;
60 delete fClient;
61}
62
63////////////////////////////////////////////////////////////////////////////////
64/// By default (for UNIX) ROOT is a single thread application
65/// For win32gdk returns kTRUE if it's called from inside of server/cmd thread
66
68{
69 return gVirtualX ? gVirtualX->IsCmdThread() : kTRUE;
70}
71
72////////////////////////////////////////////////////////////////////////////////
73/// Handle command line arguments. Arguments handled are removed from the
74/// argument array. Currently only option "-display xserver" is considered.
75
76void TRootApplication::GetOptions(Int_t *argc, char **argv)
77{
78 if (!argc) return;
79
80 int i, j;
81 for (i = 0; i < *argc; i++) {
82 if (!strcmp(argv[i], "-display")) {
83 if (argv[i+1] && strlen(argv[i+1]) && argv[i+1][0] != '-') {
84 fDisplay = StrDup(argv[i+1]);
85 argv[i] = 0;
86 argv[i+1] = 0;
87 i++;
88 }
89 }
90 }
91
92 j = 0;
93 for (i = 0; i < *argc; i++) {
94 if (argv[i]) {
95 argv[j] = argv[i];
96 j++;
97 }
98 }
99
100 *argc = j;
101}
102
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
const Bool_t kTRUE
Definition: RtypesCore.h:87
#define ClassImp(name)
Definition: Rtypes.h:365
char * StrDup(const char *str)
Duplicate the string str.
Definition: TString.cxx:2490
R__EXTERN TSystem * gSystem
Definition: TSystem.h:560
#define gVirtualX
Definition: TVirtualX.h:345
TString fApplicationName
R__ALWAYS_INLINE Bool_t IsZombie() const
Definition: TObject.h:134
void GetOptions(Int_t *argc, char **argv)
Handle command line arguments.
virtual ~TRootApplication()
Delete ROOT application environment.
Bool_t IsCmdThread()
By default (for UNIX) ROOT is a single thread application For win32gdk returns kTRUE if it's called f...
virtual void SetDisplay()
Set DISPLAY environment variable based on utmp entry. Only for UNIX.
Definition: TSystem.cxx:241