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
37
38////////////////////////////////////////////////////////////////////////////////
39/// TGuiFactory ctor only called by derived classes.
40
41TGuiFactory::TGuiFactory(const char *name, const char *title)
42 : TNamed(name, title)
43{
44}
45
46////////////////////////////////////////////////////////////////////////////////
47/// Create a batch version of TApplicationImp.
48
49TApplicationImp *TGuiFactory::CreateApplicationImp(const char *classname, int *argc, char **argv)
50{
51 return new TApplicationImp(classname, argc, argv);
52}
53
54////////////////////////////////////////////////////////////////////////////////
55/// Create a batch version of TCanvasImp.
56
58{
60 if (gROOT->IsWebDisplay()) {
61 canvName = "TWebCanvas";
62 } else {
63 canvName = gEnv->GetValue("Canvas.Name", "");
64 // in batch web display should be configured explicitely
65 if (canvName == "TWebCanvas")
66 canvName.Clear();
67 }
68
69 if (!canvName.IsNull() && (canvName != "TRootCanvas") && (canvName != "TCanvasImp")) {
70 auto ph = gROOT->GetPluginManager()->FindHandler("TCanvasImp", canvName);
71
72 if (ph && ph->LoadPlugin() != -1) {
73 auto imp = (TCanvasImp *)ph->ExecPlugin(6, c, title, 0, 0, width, height);
74 if (imp)
75 return imp;
76 }
77
78 Error("CreateCanvasImp", "Fail to create %s canvas implementation", canvName.Data());
79 }
80
81 return new TCanvasImp(c, title, width, height);
82}
83
84////////////////////////////////////////////////////////////////////////////////
85/// Create a batch version of TCanvasImp.
86
88{
90 if (gROOT->IsWebDisplay()) {
91 canvName = "TWebCanvas";
92 } else {
93 canvName = gEnv->GetValue("Canvas.Name", "");
94 // in batch web display should be configured explicitely
95 if (canvName == "TWebCanvas")
96 canvName.Clear();
97 }
98
99 if (!canvName.IsNull() && (canvName != "TRootCanvas") && (canvName != "TCanvasImp")) {
100 auto ph = gROOT->GetPluginManager()->FindHandler("TCanvasImp", canvName);
101
102 if (ph && ph->LoadPlugin() != -1) {
103 auto imp = (TCanvasImp *)ph->ExecPlugin(6, c, title, x, y, width, height);
104 if (imp)
105 return imp;
106 }
107
108 Error("CreateCanvasImp", "Fail to create %s canvas implementation", canvName.Data());
109 }
110
111 return new TCanvasImp(c, title, x, y, width, height);
112}
113
114////////////////////////////////////////////////////////////////////////////////
115/// Create a batch version of TBrowserImp.
116
118{
119 const char *browserName = nullptr;
120
121 if (gROOT->IsWebDisplay() && !gROOT->IsWebDisplayBatch())
122 browserName = "ROOT::RWebBrowserImp";
123 else if (!gROOT->IsBatch())
124 browserName = gEnv->GetValue("Browser.Name", "");
125
126 if (browserName && *browserName) {
127 auto ph = gROOT->GetPluginManager()->FindHandler("TBrowserImp", browserName);
128
129 if (ph && ph->LoadPlugin() != -1) {
130 auto imp = (TBrowserImp *)ph->ExecPlugin(5, b, title, width, height, opt);
131 if (imp)
132 return imp;
133 }
134
135 Error("CreateBrowserImp", "Fail to create %s, please provide missing libraries or run 'root --web=off'",
137 }
138
139 return new TBrowserImp(b, title, width, height);
140}
141
142////////////////////////////////////////////////////////////////////////////////
143/// Create a batch version of TBrowserImp.
144
146{
147 const char *browserName = nullptr;
148
149 if (gROOT->IsWebDisplay() && !gROOT->IsWebDisplayBatch())
150 browserName = "ROOT::RWebBrowserImp";
151 else if (!gROOT->IsBatch())
152 browserName = gEnv->GetValue("Browser.Name", "");
153
154 if (browserName && *browserName) {
155 auto ph = gROOT->GetPluginManager()->FindHandler("TBrowserImp", browserName);
156
157 if (ph && ph->LoadPlugin() != -1) {
158 auto imp = (TBrowserImp *)ph->ExecPlugin(7, b, title, x, y, width, height, opt);
159 if (imp)
160 return imp;
161 }
162
163 Error("CreateBrowserImp", "Fail to create %s, please provide missing libraries or run 'root --web=off'",
165 }
166
167 return new TBrowserImp(b, title, x, y, width, height);
168}
169
170////////////////////////////////////////////////////////////////////////////////
171/// Create a batch version of TContextMenuImp.
172
174{
175 return new TContextMenuImp(c);
176}
177
178////////////////////////////////////////////////////////////////////////////////
179/// Create a batch version of TControlBarImp.
180
182{
183 if (gROOT->IsWebDisplay()) {
184 auto ph = gROOT->GetPluginManager()->FindHandler("TControlBarImp", "TWebControlBar");
185
186 if (ph && ph->LoadPlugin() != -1) {
187 auto imp = (TControlBarImp *)ph->ExecPlugin(4, c, title, 0, 0);
188 if (imp)
189 return imp;
190 }
191
192 Error("CreateControlBarImp",
193 "Fail to create TWebControlBar, please provide missing libWebGui6 or run 'root --web=off'");
194 }
195
196 return new TControlBarImp(c, title);
197}
198
199////////////////////////////////////////////////////////////////////////////////
200/// Create a batch version of TControlBarImp.
201
203{
204 if (gROOT->IsWebDisplay()) {
205 auto ph = gROOT->GetPluginManager()->FindHandler("TControlBarImp", "TWebControlBar");
206
207 if (ph && ph->LoadPlugin() != -1) {
208 auto imp = (TControlBarImp *)ph->ExecPlugin(4, c, title, x, y);
209 if (imp)
210 return imp;
211 }
212
213 Error("CreateControlBarImp",
214 "Fail to create TWebControlBar, please provide missing libWebGui6 or run 'root --web=off'");
215 }
216
217 return new TControlBarImp(c, title, x, y);
218}
219
220////////////////////////////////////////////////////////////////////////////////
221/// Create a batch version of TInspectorImp.
222
224{
225 if (gROOT->IsBatch())
226 return new TInspectorImp(obj, width, height);
227
228 gROOT->ProcessLine(TString::Format("TInspectCanvas::Inspector((TObject*)0x%zx);", (size_t)obj).Data());
229 return nullptr;
230}
#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:81
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:126
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:148
TGuiFactory * gGuiFactory
TGuiFactory * gBatchGuiFactory
#define gROOT
Definition TROOT.h:417
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:511
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:42
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition TObject.cxx:1096
Basic string class.
Definition TString.h:138
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:2459
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17