ROOT logo
// Author: Valeri Fine   21/01/2002
/****************************************************************************
** $Id: TQtRootGuiFactory.cxx,v 1.12 2007/11/02 17:19:04 fine Exp $
**
** Copyright (C) 2002 by Valeri Fine. Brookhaven National Laboratory.
**                                    All rights reserved.
**
** This file may be distributed under the terms of the Q Public License
** as defined by Trolltech AS of Norway and appearing in the file
** LICENSE.QPL included in the packaging of this file.
**
*****************************************************************************/

//________________________________________________________________________
//////////////////////////////////////////////////////////////////////////
//                                                                      //
// TQtRootGuiFactory                                                    //
//                                                                      //
// This class is a factory for Qt GUI components. It overrides          //
// the member functions of the ABS TGuiFactory.                         //
//                                                                      //
//////////////////////////////////////////////////////////////////////////

#include "TQtRootGuiFactory.h"
#include "TRootGuiFactory.h"
#include "TQtRConfig.h"

#include "TApplication.h"
#include "TQtApplication.h"

#include "TSystem.h"
#ifdef R__QTWIN32
#  if ROOT_VERSION_CODE < ROOT_VERSION(5,13,0)
#    include "TWin32Application.h" 
#  endif
#else
# include "TROOT.h"
# include "TQtRootApplication.h"
#endif

#include "TGClient.h"
#include "TRootCanvas.h"
#include "TRootBrowser.h"
#include "TRootControlBar.h"
#include "TContextMenu.h"
#include "TRootContextMenu.h"

#include "TGQt.h"

TGClient *TQtRootGuiFactory::gfQtClient = 0;
ClassImp(TQtRootGuiFactory)
//______________________________________________________________________________
TQtRootGuiFactory::TQtRootGuiFactory()
   : TGuiFactory("QtRootProxy","Qt-based ROOT GUI Factory"),fGuiProxy(0)
{
   // TQtRootGuiFactory ctor.
   // Restore the right TVirtualX pointer      
   if (TGQt::GetVirtualX())  gVirtualX = TGQt::GetVirtualX();
   // gSystem->Load("libGui");
   fGuiProxy = new TRootGuiFactory(); 
}

//______________________________________________________________________________
TQtRootGuiFactory::TQtRootGuiFactory(const char *name, const char *title)
   : TGuiFactory(name, title),fGuiProxy(0)
{
   // TQtRootGuiFactory ctor.
   // Restore the right TVirtualX pointer      
   if (TGQt::GetVirtualX())  gVirtualX = TGQt::GetVirtualX();
   // gSystem->Load("libGui");
   fGuiProxy = new TRootGuiFactory(name,title); 
}
//______________________________________________________________________________
TApplicationImp *TQtRootGuiFactory::CreateApplicationImp(const char *classname, int *argc, char **argv)
{
 TGQt::CreateQtApplicationImp();
 TApplicationImp *app = 0;
#ifdef R__QTWIN32
#  if ROOT_VERSION_CODE < ROOT_VERSION(5,13,0)
    app = new TWin32Application(classname, argc, argv);
#  endif 
#else
  app = new TQtRootApplication (classname, argc, argv);
#endif
  CreateQClient();
  return app;        
}
//______________________________________________________________________________
void TQtRootGuiFactory::CreateQClient()
{ 
    gfQtClient = new TGClient();
   // ((TQt *)TQt::GetVirtualX())->SetQClientFilter(new TQClientFilter(new TGClient()));
}

//______________________________________________________________________________
TCanvasImp *TQtRootGuiFactory::CreateCanvasImp(TCanvas *c, const char *title, UInt_t width, UInt_t height)
{ return fGuiProxy ? fGuiProxy->CreateCanvasImp( c, title, width, height) : 0; }

//______________________________________________________________________________
TCanvasImp *TQtRootGuiFactory::CreateCanvasImp(TCanvas *c, const char *title, Int_t x, Int_t y, UInt_t width, UInt_t height)
{ return fGuiProxy ? fGuiProxy->CreateCanvasImp(c, title, x, y, width, height) : 0 ;}

//______________________________________________________________________________
TBrowserImp *TQtRootGuiFactory::CreateBrowserImp(TBrowser *b, const char *title, UInt_t width, UInt_t height)
{
   return CreateBrowserImp(b, title, width, height, (Option_t *)0);
}

//______________________________________________________________________________
TBrowserImp *TQtRootGuiFactory::CreateBrowserImp(TBrowser *b, const char *title, Int_t x, Int_t y, UInt_t width, UInt_t height)
{
  return CreateBrowserImp(b, title, x, y, width, height, (Option_t *)0);
}

//______________________________________________________________________________
TBrowserImp *TQtRootGuiFactory::CreateBrowserImp(TBrowser *b, const char *title, UInt_t width, UInt_t height,Option_t *opt)
{ 
   return fGuiProxy ? 
#if ROOT_VERSION_CODE < ROOT_VERSION(5,17,5)
      fGuiProxy->CreateBrowserImp(b, title, width, height)
#else
      fGuiProxy->CreateBrowserImp(b, title, width, height, opt)
#endif
      : 0; 
}

//______________________________________________________________________________
TBrowserImp *TQtRootGuiFactory::CreateBrowserImp(TBrowser *b, const char *title, Int_t x, Int_t y, UInt_t width, UInt_t height,Option_t *opt)
{ 
   return fGuiProxy ? 
#if ROOT_VERSION_CODE < ROOT_VERSION(5,17,5)
      fGuiProxy->CreateBrowserImp(b, title, x, y, width, height)
#else
      fGuiProxy->CreateBrowserImp(b, title, x, y, width, height, opt)
#endif
      : 0 ; 
}

//______________________________________________________________________________
TContextMenuImp *TQtRootGuiFactory::CreateContextMenuImp(TContextMenu *c, const char *name, const char *title)
{ return fGuiProxy ? fGuiProxy->CreateContextMenuImp(c, name, title): 0;} 

//______________________________________________________________________________
TControlBarImp *TQtRootGuiFactory::CreateControlBarImp(TControlBar *c, const char *title)
{ return fGuiProxy ? fGuiProxy->CreateControlBarImp(c,title) : 0;}

//______________________________________________________________________________
TControlBarImp *TQtRootGuiFactory::CreateControlBarImp(TControlBar *c, const char *title, Int_t x, Int_t y)
{ return fGuiProxy ? fGuiProxy->CreateControlBarImp(c, title, x, y):0;}

//______________________________________________________________________________
TInspectorImp *TQtRootGuiFactory::CreateInspectorImp(const TObject *obj, UInt_t width, UInt_t height)
{ return fGuiProxy ? fGuiProxy->CreateInspectorImp(obj, width, height) :0 ;}
 TQtRootGuiFactory.cxx:1
 TQtRootGuiFactory.cxx:2
 TQtRootGuiFactory.cxx:3
 TQtRootGuiFactory.cxx:4
 TQtRootGuiFactory.cxx:5
 TQtRootGuiFactory.cxx:6
 TQtRootGuiFactory.cxx:7
 TQtRootGuiFactory.cxx:8
 TQtRootGuiFactory.cxx:9
 TQtRootGuiFactory.cxx:10
 TQtRootGuiFactory.cxx:11
 TQtRootGuiFactory.cxx:12
 TQtRootGuiFactory.cxx:13
 TQtRootGuiFactory.cxx:14
 TQtRootGuiFactory.cxx:15
 TQtRootGuiFactory.cxx:16
 TQtRootGuiFactory.cxx:17
 TQtRootGuiFactory.cxx:18
 TQtRootGuiFactory.cxx:19
 TQtRootGuiFactory.cxx:20
 TQtRootGuiFactory.cxx:21
 TQtRootGuiFactory.cxx:22
 TQtRootGuiFactory.cxx:23
 TQtRootGuiFactory.cxx:24
 TQtRootGuiFactory.cxx:25
 TQtRootGuiFactory.cxx:26
 TQtRootGuiFactory.cxx:27
 TQtRootGuiFactory.cxx:28
 TQtRootGuiFactory.cxx:29
 TQtRootGuiFactory.cxx:30
 TQtRootGuiFactory.cxx:31
 TQtRootGuiFactory.cxx:32
 TQtRootGuiFactory.cxx:33
 TQtRootGuiFactory.cxx:34
 TQtRootGuiFactory.cxx:35
 TQtRootGuiFactory.cxx:36
 TQtRootGuiFactory.cxx:37
 TQtRootGuiFactory.cxx:38
 TQtRootGuiFactory.cxx:39
 TQtRootGuiFactory.cxx:40
 TQtRootGuiFactory.cxx:41
 TQtRootGuiFactory.cxx:42
 TQtRootGuiFactory.cxx:43
 TQtRootGuiFactory.cxx:44
 TQtRootGuiFactory.cxx:45
 TQtRootGuiFactory.cxx:46
 TQtRootGuiFactory.cxx:47
 TQtRootGuiFactory.cxx:48
 TQtRootGuiFactory.cxx:49
 TQtRootGuiFactory.cxx:50
 TQtRootGuiFactory.cxx:51
 TQtRootGuiFactory.cxx:52
 TQtRootGuiFactory.cxx:53
 TQtRootGuiFactory.cxx:54
 TQtRootGuiFactory.cxx:55
 TQtRootGuiFactory.cxx:56
 TQtRootGuiFactory.cxx:57
 TQtRootGuiFactory.cxx:58
 TQtRootGuiFactory.cxx:59
 TQtRootGuiFactory.cxx:60
 TQtRootGuiFactory.cxx:61
 TQtRootGuiFactory.cxx:62
 TQtRootGuiFactory.cxx:63
 TQtRootGuiFactory.cxx:64
 TQtRootGuiFactory.cxx:65
 TQtRootGuiFactory.cxx:66
 TQtRootGuiFactory.cxx:67
 TQtRootGuiFactory.cxx:68
 TQtRootGuiFactory.cxx:69
 TQtRootGuiFactory.cxx:70
 TQtRootGuiFactory.cxx:71
 TQtRootGuiFactory.cxx:72
 TQtRootGuiFactory.cxx:73
 TQtRootGuiFactory.cxx:74
 TQtRootGuiFactory.cxx:75
 TQtRootGuiFactory.cxx:76
 TQtRootGuiFactory.cxx:77
 TQtRootGuiFactory.cxx:78
 TQtRootGuiFactory.cxx:79
 TQtRootGuiFactory.cxx:80
 TQtRootGuiFactory.cxx:81
 TQtRootGuiFactory.cxx:82
 TQtRootGuiFactory.cxx:83
 TQtRootGuiFactory.cxx:84
 TQtRootGuiFactory.cxx:85
 TQtRootGuiFactory.cxx:86
 TQtRootGuiFactory.cxx:87
 TQtRootGuiFactory.cxx:88
 TQtRootGuiFactory.cxx:89
 TQtRootGuiFactory.cxx:90
 TQtRootGuiFactory.cxx:91
 TQtRootGuiFactory.cxx:92
 TQtRootGuiFactory.cxx:93
 TQtRootGuiFactory.cxx:94
 TQtRootGuiFactory.cxx:95
 TQtRootGuiFactory.cxx:96
 TQtRootGuiFactory.cxx:97
 TQtRootGuiFactory.cxx:98
 TQtRootGuiFactory.cxx:99
 TQtRootGuiFactory.cxx:100
 TQtRootGuiFactory.cxx:101
 TQtRootGuiFactory.cxx:102
 TQtRootGuiFactory.cxx:103
 TQtRootGuiFactory.cxx:104
 TQtRootGuiFactory.cxx:105
 TQtRootGuiFactory.cxx:106
 TQtRootGuiFactory.cxx:107
 TQtRootGuiFactory.cxx:108
 TQtRootGuiFactory.cxx:109
 TQtRootGuiFactory.cxx:110
 TQtRootGuiFactory.cxx:111
 TQtRootGuiFactory.cxx:112
 TQtRootGuiFactory.cxx:113
 TQtRootGuiFactory.cxx:114
 TQtRootGuiFactory.cxx:115
 TQtRootGuiFactory.cxx:116
 TQtRootGuiFactory.cxx:117
 TQtRootGuiFactory.cxx:118
 TQtRootGuiFactory.cxx:119
 TQtRootGuiFactory.cxx:120
 TQtRootGuiFactory.cxx:121
 TQtRootGuiFactory.cxx:122
 TQtRootGuiFactory.cxx:123
 TQtRootGuiFactory.cxx:124
 TQtRootGuiFactory.cxx:125
 TQtRootGuiFactory.cxx:126
 TQtRootGuiFactory.cxx:127
 TQtRootGuiFactory.cxx:128
 TQtRootGuiFactory.cxx:129
 TQtRootGuiFactory.cxx:130
 TQtRootGuiFactory.cxx:131
 TQtRootGuiFactory.cxx:132
 TQtRootGuiFactory.cxx:133
 TQtRootGuiFactory.cxx:134
 TQtRootGuiFactory.cxx:135
 TQtRootGuiFactory.cxx:136
 TQtRootGuiFactory.cxx:137
 TQtRootGuiFactory.cxx:138
 TQtRootGuiFactory.cxx:139
 TQtRootGuiFactory.cxx:140
 TQtRootGuiFactory.cxx:141
 TQtRootGuiFactory.cxx:142
 TQtRootGuiFactory.cxx:143
 TQtRootGuiFactory.cxx:144
 TQtRootGuiFactory.cxx:145
 TQtRootGuiFactory.cxx:146
 TQtRootGuiFactory.cxx:147
 TQtRootGuiFactory.cxx:148
 TQtRootGuiFactory.cxx:149
 TQtRootGuiFactory.cxx:150
 TQtRootGuiFactory.cxx:151
 TQtRootGuiFactory.cxx:152
 TQtRootGuiFactory.cxx:153