Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TGuiFactory.cxx
Go to the documentation of this file.
1// @(#)root/base:$Id$
2// Author: Fons Rademakers 15/11/95
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/** \class TGuiFactory
13\ingroup Base
14
15This ABC is a factory for GUI components. Depending on which
16factory is active one gets either ROOT native (X11 based with Win95
17look and feel), Win32 or Mac components.
18
19In case there is no platform dependent implementation on can run in
20batch mode directly using an instance of this base class.
21*/
22
23#include "TGuiFactory.h"
24#include "TApplicationImp.h"
25#include "TCanvasImp.h"
26#include "TBrowserImp.h"
27#include "TContextMenuImp.h"
28#include "TControlBarImp.h"
29#include "TInspectorImp.h"
30#include "TROOT.h"
31#include "TEnv.h"
32#include "TPluginManager.h"
33
36
38
39////////////////////////////////////////////////////////////////////////////////
40/// TGuiFactory ctor only called by derived classes.
41
42TGuiFactory::TGuiFactory(const char *name, const char *title)
43 : TNamed(name, title)
44{
45}
46
47////////////////////////////////////////////////////////////////////////////////
48/// Create a batch version of TApplicationImp.
49
50TApplicationImp *TGuiFactory::CreateApplicationImp(const char *classname, int *argc, char **argv)
51{
52 return new TApplicationImp(classname, argc, argv);
53}
54
55////////////////////////////////////////////////////////////////////////////////
56/// Create a batch version of TCanvasImp.
57
59{
60 if (gROOT->IsWebDisplay()) {
61 auto ph = gROOT->GetPluginManager()->FindHandler("TCanvasImp", "TWebCanvas");
62
63 if (ph && ph->LoadPlugin() != -1) {
64 auto imp = (TCanvasImp *) ph->ExecPlugin(6, c, title, 0, 0, width, height);
65 if (imp) return imp;
66 }
67 }
68
69 return new TCanvasImp(c, title, width, height);
70}
71
72////////////////////////////////////////////////////////////////////////////////
73/// Create a batch version of TCanvasImp.
74
76{
77 if (gROOT->IsWebDisplay()) {
78 auto ph = gROOT->GetPluginManager()->FindHandler("TCanvasImp", "TWebCanvas");
79
80 if (ph && ph->LoadPlugin() != -1) {
81 auto imp = (TCanvasImp *) ph->ExecPlugin(6, c, title, x, y, width, height);
82 if (imp) return imp;
83 }
84 }
85
86 return new TCanvasImp(c, title, x, y, width, height);
87}
88
89////////////////////////////////////////////////////////////////////////////////
90/// Create a batch version of TBrowserImp.
91
93{
94 const char *browserName = nullptr;
95
96 if (gROOT->IsWebDisplay() && !gROOT->IsWebDisplayBatch())
97 browserName = "ROOT::Experimental::RWebBrowserImp";
98 else if (!gROOT->IsBatch()) {
99 browserName = gEnv->GetValue("Browser.Name", "");
100 if (strcmp(browserName, "ROOT::Experimental::RWebBrowserImp") == 0) {
101 printf("\nWARNING!\n");
102 printf("rootrc parameter \"Browser.Name\" with web browser disabled for security reasons.\n");
103 printf("See https://root.cern/about/security/#2023-11-26-open-port-for-control-of-web-gui-allows-read-and-write-access-to-file-system for more information.\n");
104 printf("For environments controlling the security issues you can enable web display by calling\n");
105 printf("gROOT->SetWebDisplay(); in ROOT prompt or in startup scripts\n\n");
106
107 browserName = "TRootBrowser";
108 }
109 }
110
111 if (browserName && *browserName) {
112 auto ph = gROOT->GetPluginManager()->FindHandler("TBrowserImp", browserName);
113
114 if (ph && ph->LoadPlugin() != -1) {
115 TBrowserImp *imp = (TBrowserImp *)ph->ExecPlugin(5, b, title, width, height, opt);
116 if (imp) return imp;
117 }
118 }
119
120 return new TBrowserImp(b, title, width, height);
121}
122
123////////////////////////////////////////////////////////////////////////////////
124/// Create a batch version of TBrowserImp.
125
127{
128 const char *browserName = nullptr;
129
130 if (gROOT->IsWebDisplay() && !gROOT->IsWebDisplayBatch())
131 browserName = "ROOT::Experimental::RWebBrowserImp";
132 else if (!gROOT->IsBatch()) {
133 browserName = gEnv->GetValue("Browser.Name", "");
134 if (strcmp(browserName, "ROOT::Experimental::RWebBrowserImp") == 0) {
135 printf("\nWARNING!\n");
136 printf("rootrc parameter \"Browser.Name\" with web browser disabled for security reason.\n");
137 printf("See https://root.cern/about/security/#2023-11-26-open-port-for-control-of-web-gui-allows-read-and-write-access-to-file-system for more information.\n");
138 printf("For environments controlling the security issues you can enable web display by calling\n");
139 printf("gROOT->SetWebDisplay(); in ROOT prompt or in startup scripts\n\n");
140
141 browserName = "TRootBrowser";
142 }
143 }
144
145 if (browserName && *browserName) {
146 auto ph = gROOT->GetPluginManager()->FindHandler("TBrowserImp", browserName);
147
148 if (ph && ph->LoadPlugin() != -1) {
149 TBrowserImp *imp = (TBrowserImp *)ph->ExecPlugin(7, b, title, x, y, width, height, opt);
150 if (imp) return imp;
151 }
152 }
153
154 return new TBrowserImp(b, title, x, y, width, height);
155}
156
157////////////////////////////////////////////////////////////////////////////////
158/// Create a batch version of TContextMenuImp.
159
161{
162 return new TContextMenuImp(c);
163}
164
165////////////////////////////////////////////////////////////////////////////////
166/// Create a batch version of TControlBarImp.
167
169{
170 if (gROOT->IsWebDisplay()) {
171 auto ph = gROOT->GetPluginManager()->FindHandler("TControlBarImp", "TWebControlBar");
172
173 if (ph && ph->LoadPlugin() != -1) {
174 auto imp = (TControlBarImp *) ph->ExecPlugin(4, c, title, 0, 0);
175 if (imp) return imp;
176 }
177 }
178
179 return new TControlBarImp(c, title);
180}
181
182////////////////////////////////////////////////////////////////////////////////
183/// Create a batch version of TControlBarImp.
184
186{
187 if (gROOT->IsWebDisplay()) {
188 auto ph = gROOT->GetPluginManager()->FindHandler("TControlBarImp", "TWebControlBar");
189
190 if (ph && ph->LoadPlugin() != -1) {
191 auto imp = (TControlBarImp *) ph->ExecPlugin(4, c, title, x, y);
192 if (imp) return imp;
193 }
194 }
195
196 return new TControlBarImp(c, title, x, y);
197}
198
199////////////////////////////////////////////////////////////////////////////////
200/// Create a batch version of TInspectorImp.
201
203{
204 if (gROOT->IsBatch())
205 return new TInspectorImp(obj, width, height);
206
207 gROOT->ProcessLine(TString::Format("TInspectCanvas::Inspector((TObject*)0x%zx);", (size_t)obj).Data());
208 return nullptr;
209}
#define b(i)
Definition RSha256.hxx:100
#define c(i)
Definition RSha256.hxx:101
const char Option_t
Definition RtypesCore.h:66
#define ClassImp(name)
Definition Rtypes.h:377
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
TGuiFactory * gGuiFactory
TGuiFactory * gBatchGuiFactory
#define gROOT
Definition TROOT.h:405
ABC describing GUI independent application implementation protocol.
ABC describing GUI independent browser implementation protocol.
Definition TBrowserImp.h:29
virtual Longptr_t ExecPlugin(const char *, const char *, const char *, Int_t, Int_t)
Definition TBrowserImp.h:59
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:491
This ABC is a factory for GUI components.
Definition TGuiFactory.h:42
virtual TApplicationImp * CreateApplicationImp(const char *classname, int *argc, char **argv)
Create a batch version of TApplicationImp.
TGuiFactory(const char *name="Batch", const char *title="Batch GUI Factory")
TGuiFactory ctor only called by derived classes.
virtual TContextMenuImp * CreateContextMenuImp(TContextMenu *c, const char *name, const char *title)
Create a batch version of TContextMenuImp.
virtual TInspectorImp * CreateInspectorImp(const TObject *obj, UInt_t width, UInt_t height)
Create a batch version of TInspectorImp.
virtual TBrowserImp * CreateBrowserImp(TBrowser *b, const char *title, UInt_t width, UInt_t height, Option_t *opt="")
Create a batch version of TBrowserImp.
virtual TCanvasImp * CreateCanvasImp(TCanvas *c, const char *title, UInt_t width, UInt_t height)
Create a batch version of TCanvasImp.
virtual TControlBarImp * CreateControlBarImp(TControlBar *c, const char *title)
Create a batch version of TControlBarImp.
ABC describing GUI independent object inspector (abstraction mainly needed for Win32.
The TNamed class is the base class for all named ROOT classes.
Definition TNamed.h:29
Mother of all ROOT objects.
Definition TObject.h:41
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
Definition TString.cxx:2356
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17