Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TRootGuiFactory.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/** \class TRootGuiFactory
14 \ingroup guiwidgets
15
16This class is a factory for ROOT GUI components. It overrides
17the member functions of the ABS TGuiFactory.
18
19*/
20
21
22#include "TRootGuiFactory.h"
23#include "TRootApplication.h"
24#include "TRootCanvas.h"
25#include "TRootBrowser.h"
26#include "TRootBrowserLite.h"
27#include "TRootContextMenu.h"
28#include "TRootControlBar.h"
29#include "TROOT.h"
30#include "TPluginManager.h"
31#include "TEnv.h"
32
33#include <iostream>
34
35
36////////////////////////////////////////////////////////////////////////////////
37/// TRootGuiFactory ctor.
38
39TRootGuiFactory::TRootGuiFactory(const char *name, const char *title)
40 : TGuiFactory(name, title)
41{
42}
43
44////////////////////////////////////////////////////////////////////////////////
45/// Create a ROOT native GUI version of TApplicationImp
46
48 Int_t *argc, char **argv)
49{
50 TRootApplication *app = new TRootApplication(classname, argc, argv);
51 if (!app->Client()) {
52 delete app;
53 app = nullptr;
54 }
55 return app;
56}
57
58////////////////////////////////////////////////////////////////////////////////////////
59/// Show warning that TWebCanvas will be started by default
60
62{
63 static bool show_warn = true;
64 if (!show_warn || gROOT->IsWebDisplay()) return;
65 show_warn = false;
66
67 std::cout << "\n"
68 "ROOT comes with a web-based canvas, which is now being started. \n"
69 "Revert to the legacy canvas by setting \"Canvas.Name: TRootCanvas\" in rootrc file or\n"
70 "by starting \"root --web=off\".\n"
71 "Find more info on https://root.cern/for_developers/root7/#twebcanvas\n";
72}
73
74////////////////////////////////////////////////////////////////////////////////
75/// Create a ROOT native GUI version of TCanvasImp
76
79{
80 TString canvName = gEnv->GetValue("Canvas.Name", "TWebCanvas");
81 if (canvName == "TWebCanvas") {
82 auto ph = gROOT->GetPluginManager()->FindHandler("TCanvasImp", "TWebCanvas");
83
84 if (ph && ph->LoadPlugin() != -1) {
86 auto imp = (TCanvasImp *) ph->ExecPlugin(6, c, title, 0, 0, width, height);
87 if (imp) return imp;
88 }
89 }
90
91 return new TRootCanvas(c, title, width, height);
92}
93
94////////////////////////////////////////////////////////////////////////////////
95/// Create a ROOT native GUI version of TCanvasImp
96
99{
100 TString canvName = gEnv->GetValue("Canvas.Name", "TWebCanvas");
101 if (canvName == "TWebCanvas") {
102 auto ph = gROOT->GetPluginManager()->FindHandler("TCanvasImp", "TWebCanvas");
103
104 if (ph && ph->LoadPlugin() != -1) {
106 auto imp = (TCanvasImp *) ph->ExecPlugin(6, c, title, x, y, width, height);
107 if (imp) return imp;
108 }
109 }
110
111 return new TRootCanvas(c, title, x, y, width, height);
112}
113
114////////////////////////////////////////////////////////////////////////////////
115/// Create a ROOT native GUI version of TBrowserImp
116
119 Option_t *opt)
120{
121 TString browserVersion(gEnv->GetValue("Browser.Name", "TRootBrowserLite"));
122 TPluginHandler *ph = gROOT->GetPluginManager()->FindHandler("TBrowserImp",
124 TString browserOptions(gEnv->GetValue("Browser.Options", "FECI"));
125 if (opt && strlen(opt))
126 browserOptions = opt;
127 browserOptions.ToUpper();
128 if (browserOptions.Contains("LITE"))
129 return new TRootBrowserLite(b, title, width, height);
130 if (ph && ph->LoadPlugin() != -1) {
131 TBrowserImp *imp = (TBrowserImp *)ph->ExecPlugin(5, b, title, width,
132 height, browserOptions.Data());
133 if (imp) return imp;
134 }
135 if (browserVersion.Contains("Lite", TString::kIgnoreCase))
136 return new TRootBrowserLite(b, title, width, height);
137 else
138 return new TRootBrowser(b, title, width, height, browserOptions.Data());
139}
140
141////////////////////////////////////////////////////////////////////////////////
142/// Create a ROOT native GUI version of TBrowserImp
143
146 UInt_t height, Option_t *opt)
147{
148 TString browserVersion(gEnv->GetValue("Browser.Name", "TRootBrowserLite"));
149 TPluginHandler *ph = gROOT->GetPluginManager()->FindHandler("TBrowserImp",
151 TString browserOptions(gEnv->GetValue("Browser.Options", "FECI"));
152 if (opt && strlen(opt))
153 browserOptions = opt;
154 browserOptions.ToUpper();
155 if (browserOptions.Contains("LITE"))
156 return new TRootBrowserLite(b, title, width, height);
157 if (ph && ph->LoadPlugin() != -1) {
158 TBrowserImp *imp = (TBrowserImp *)ph->ExecPlugin(7, b, title, x, y, width,
159 height, browserOptions.Data());
160 if (imp) return imp;
161 }
162 if (browserVersion.Contains("Lite", TString::kIgnoreCase))
163 return new TRootBrowserLite(b, title, x, y, width, height);
164 else
165 return new TRootBrowser(b, title, x, y, width, height, browserOptions.Data());
166}
167
168////////////////////////////////////////////////////////////////////////////////
169/// Create a ROOT native GUI version of TContextMenuImp
170
172 const char *name, const char *)
173{
174 return new TRootContextMenu(c, name);
175}
176
177////////////////////////////////////////////////////////////////////////////////
178/// Create a ROOT native GUI version of TControlBarImp
179
181{
182 if (gROOT->IsWebDisplay())
183 return TGuiFactory::CreateControlBarImp(c, title);
184
185 return new TRootControlBar(c, title);
186}
187
188////////////////////////////////////////////////////////////////////////////////
189/// Create a ROOT native GUI version of TControlBarImp
190
192 Int_t x, Int_t y)
193{
194 if (gROOT->IsWebDisplay())
195 return TGuiFactory::CreateControlBarImp(c, title, x, y);
196
197 return new TRootControlBar(c, title, x, y);
198}
#define b(i)
Definition RSha256.hxx:100
#define c(i)
Definition RSha256.hxx:101
const char Option_t
Option string (const char)
Definition RtypesCore.h:80
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
R__EXTERN TEnv * gEnv
Definition TEnv.h:170
Option_t Option_t width
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t height
char name[80]
Definition TGX11.cxx:110
#define gROOT
Definition TROOT.h:411
ABC describing GUI independent application implementation protocol.
ABC describing GUI independent browser implementation protocol.
Definition TBrowserImp.h:29
Using a TBrowser one can browse all ROOT objects.
Definition TBrowser.h:37
ABC describing GUI independent main window (with menubar, scrollbars and a drawing area).
Definition TCanvasImp.h:30
The Canvas class.
Definition TCanvas.h:23
This class provides an interface to GUI independent context sensitive popup menus.
This class provides an interface to context sensitive popup menus.
ABC describing GUI independent control bar.
A Control Bar is a fully user configurable tool which provides fast access to frequently used operati...
Definition TControlBar.h:26
virtual Int_t GetValue(const char *name, Int_t dflt) const
Returns the integer value for a resource.
Definition TEnv.cxx:490
This ABC is a factory for GUI components.
Definition TGuiFactory.h:42
virtual TControlBarImp * CreateControlBarImp(TControlBar *c, const char *title)
Create a batch version of TControlBarImp.
This class create the ROOT native GUI version of the ROOT application environment.
This class creates a ROOT object browser (looking like Windows Explorer).
This class creates a ROOT object browser, constituted by three main tabs.
This class creates a main window with menubar, scrollbars and a drawing area.
Definition TRootCanvas.h:34
This class provides an interface to context sensitive popup menus.
This class provides an interface to the GUI dependent functions of the TControlBar class.
TCanvasImp * CreateCanvasImp(TCanvas *c, const char *title, UInt_t width, UInt_t height) override
Create a ROOT native GUI version of TCanvasImp.
void ShowWebCanvasWarning()
Show warning that TWebCanvas will be started by default.
TControlBarImp * CreateControlBarImp(TControlBar *c, const char *title) override
Create a ROOT native GUI version of TControlBarImp.
TRootGuiFactory(const char *name="Root", const char *title="ROOT GUI Factory")
TRootGuiFactory ctor.
TApplicationImp * CreateApplicationImp(const char *classname, int *argc, char **argv) override
Create a ROOT native GUI version of TApplicationImp.
TContextMenuImp * CreateContextMenuImp(TContextMenu *c, const char *name, const char *title) override
Create a ROOT native GUI version of TContextMenuImp.
TBrowserImp * CreateBrowserImp(TBrowser *b, const char *title, UInt_t width, UInt_t height, Option_t *opt="") override
Create a ROOT native GUI version of TBrowserImp.
Basic string class.
Definition TString.h:138
@ kIgnoreCase
Definition TString.h:285
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17