#include "TRootGuiFactory.h"
#include "TRootApplication.h"
#include "TRootCanvas.h"
#include "TRootBrowserLite.h"
#include "TRootContextMenu.h"
#include "TRootControlBar.h"
#include "TROOT.h"
#include "TPluginManager.h"
#include "TEnv.h"
ClassImp(TRootGuiFactory)
TRootGuiFactory::TRootGuiFactory(const char *name, const char *title)
: TGuiFactory(name, title)
{
}
TApplicationImp *TRootGuiFactory::CreateApplicationImp(const char *classname,
Int_t *argc, char **argv)
{
TRootApplication *app = new TRootApplication(classname, argc, argv);
if (!app->Client()) {
delete app;
app = 0;
}
return app;
}
TCanvasImp *TRootGuiFactory::CreateCanvasImp(TCanvas *c, const char *title,
UInt_t width, UInt_t height)
{
return new TRootCanvas(c, title, width, height);
}
TCanvasImp *TRootGuiFactory::CreateCanvasImp(TCanvas *c, const char *title,
Int_t x, Int_t y, UInt_t width, UInt_t height)
{
return new TRootCanvas(c, title, x, y, width, height);
}
TBrowserImp *TRootGuiFactory::CreateBrowserImp(TBrowser *b, const char *title,
UInt_t width, UInt_t height,
Option_t *opt)
{
TString browserVersion(gEnv->GetValue("Browser.Name", "TRootBrowserLite"));
TPluginHandler *ph = gROOT->GetPluginManager()->FindHandler("TBrowserImp",
browserVersion);
TString browserOptions(gEnv->GetValue("Browser.Options", "FECI"));
if (opt && strlen(opt))
browserOptions = opt;
browserOptions.ToUpper();
if (browserOptions.Contains("LITE"))
return new TRootBrowserLite(b, title, width, height);
if (ph && ph->LoadPlugin() != -1) {
TBrowserImp *imp = (TBrowserImp *)ph->ExecPlugin(5, b, title, width,
height, browserOptions.Data());
if (imp) return imp;
}
return new TRootBrowserLite(b, title, width, height);
}
TBrowserImp *TRootGuiFactory::CreateBrowserImp(TBrowser *b, const char *title,
Int_t x, Int_t y, UInt_t width,
UInt_t height, Option_t *opt)
{
TString browserVersion(gEnv->GetValue("Browser.Name", "TRootBrowserLite"));
TPluginHandler *ph = gROOT->GetPluginManager()->FindHandler("TBrowserImp",
browserVersion);
TString browserOptions(gEnv->GetValue("Browser.Options", "FECI"));
if (opt && strlen(opt))
browserOptions = opt;
browserOptions.ToUpper();
if (browserOptions.Contains("LITE"))
return new TRootBrowserLite(b, title, width, height);
if (ph && ph->LoadPlugin() != -1) {
TBrowserImp *imp = (TBrowserImp *)ph->ExecPlugin(7, b, title, x, y, width,
height, browserOptions.Data());
if (imp) return imp;
}
return new TRootBrowserLite(b, title, x, y, width, height);
}
TContextMenuImp *TRootGuiFactory::CreateContextMenuImp(TContextMenu *c,
const char *name, const char *)
{
return new TRootContextMenu(c, name);
}
TControlBarImp *TRootGuiFactory::CreateControlBarImp(TControlBar *c, const char *title)
{
return new TRootControlBar(c, title);
}
TControlBarImp *TRootGuiFactory::CreateControlBarImp(TControlBar *c, const char *title,
Int_t x, Int_t y)
{
return new TRootControlBar(c, title, x, y);
}