Logo ROOT  
Reference Guide
RWebDisplayArgs.hxx
Go to the documentation of this file.
1// Author: Sergey Linev <s.linev@gsi.de>
2// Date: 2018-10-24
3// Warning: This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback is welcome!
4
5/*************************************************************************
6 * Copyright (C) 1995-2019, Rene Brun and Fons Rademakers. *
7 * All rights reserved. *
8 * *
9 * For the licensing terms see $ROOTSYS/LICENSE. *
10 * For the list of contributors see $ROOTSYS/README/CREDITS. *
11 *************************************************************************/
12
13#ifndef ROOT7_RWebDisplayArgs
14#define ROOT7_RWebDisplayArgs
15
16#include <string>
17#include <memory>
18
19class THttpServer;
20
21namespace ROOT {
22namespace Experimental {
23
24class RLogChannel;
25/// Log channel for WebGUI diagnostics.
26RLogChannel &WebGUILog();
27
28class RWebWindow;
29
31
32friend class RWebWindow;
33
34public:
36 kChrome, ///< Google Chrome browser
37 kFirefox, ///< Mozilla Firefox browser
38 kNative, ///< either Chrome or Firefox - both support major functionality
39 kCEF, ///< Chromium Embedded Framework - local display with CEF libs
40 kQt5, ///< Qt5 QWebEngine libraries - Chromium code packed in qt5
41 kQt6, ///< Qt6 QWebEngine libraries - Chromium code packed in qt6
42 kLocal, ///< either CEF or Qt5 - both runs on local display without real http server
43 kStandard, ///< standard system web browser, not recognized by ROOT, without batch mode
44 kEmbedded, ///< window will be embedded into other, no extra browser need to be started
45 kCustom ///< custom web browser, execution string should be provided
46 };
47
48protected:
49 EBrowserKind fKind{kNative}; ///<! id of web browser used for display
50 std::string fUrl; ///<! URL to display
51 std::string fExtraArgs; ///<! extra arguments which will be append to exec string
52 std::string fPageContent; ///<! HTML page content
53 std::string fRedirectOutput; ///<! filename where browser output should be redirected
54 std::string fWidgetKind; ///<! widget kind, used to identify that will be displayed in the web window
55 bool fBatchMode{false}; ///<! is browser runs in batch mode
56 bool fHeadless{false}; ///<! is browser runs in headless mode
57 bool fStandalone{true}; ///<! indicates if browser should run isolated from other browser instances
58 THttpServer *fServer{nullptr}; ///<! http server which handle all requests
59 int fWidth{0}; ///<! custom window width, when not specified - used RWebWindow geometry
60 int fHeight{0}; ///<! custom window height, when not specified - used RWebWindow geometry
61 int fX{-1}; ///<! custom window x position, negative is default
62 int fY{-1}; ///<! custom window y position, negative is default
63 std::string fUrlOpt; ///<! extra URL options, which are append to window URL
64 std::string fExec; ///<! string to run browser, used with kCustom type
65 void *fDriverData{nullptr}; ///<! special data delivered to driver, can be used for QWebEngine
66
67 std::shared_ptr<RWebWindow> fMaster; ///<! master window
68 int fMasterChannel{-1}; ///<! used master channel
69
70 bool SetSizeAsStr(const std::string &str);
71 bool SetPosAsStr(const std::string &str);
72
73public:
75
76 RWebDisplayArgs(const std::string &browser);
77
78 RWebDisplayArgs(const char *browser);
79
80 RWebDisplayArgs(int width, int height, int x = -1, int y = -1, const std::string &browser = "");
81
82 RWebDisplayArgs(std::shared_ptr<RWebWindow> master, int channel = -1);
83
84 virtual ~RWebDisplayArgs();
85
86 RWebDisplayArgs &SetBrowserKind(const std::string &kind);
87 /// set browser kind, see EBrowserKind for allowed values
88 RWebDisplayArgs &SetBrowserKind(EBrowserKind kind) { fKind = kind; return *this; }
89 /// returns configured browser kind, see EBrowserKind for supported values
90 EBrowserKind GetBrowserKind() const { return fKind; }
91 std::string GetBrowserName() const;
92
93 void SetMasterWindow(std::shared_ptr<RWebWindow> master, int channel = -1);
94
95 /// returns true if local display like CEF or Qt5 QWebEngine should be used
96 bool IsLocalDisplay() const
97 {
98 return (GetBrowserKind() == kLocal) || (GetBrowserKind() == kCEF) || (GetBrowserKind() == kQt5) || (GetBrowserKind() == kQt6);
99 }
100
101 /// returns true if browser supports headless mode
102 bool IsSupportHeadless() const
103 {
104 return (GetBrowserKind() == kNative) || (GetBrowserKind() == kChrome) || (GetBrowserKind() == kFirefox) || (GetBrowserKind() == kCEF) || (GetBrowserKind() == kQt5) || (GetBrowserKind() == kQt6);
105 }
106
107 /// set window url
108 RWebDisplayArgs &SetUrl(const std::string &url) { fUrl = url; return *this; }
109 /// returns window url
110 const std::string &GetUrl() const { return fUrl; }
111
112 /// set widget kind
113 RWebDisplayArgs &SetWidgetKind(const std::string &kind) { fWidgetKind = kind; return *this; }
114 /// returns widget kind
115 const std::string &GetWidgetKind() const { return fWidgetKind; }
116
117 /// set window url
118 RWebDisplayArgs &SetPageContent(const std::string &cont) { fPageContent = cont; return *this; }
119 /// returns window url
120 const std::string &GetPageContent() const { return fPageContent; }
121
122 /// Set standalone mode for running browser, default on
123 /// When disabled, normal browser window (or just tab) will be started
124 void SetStandalone(bool on = true) { fStandalone = on; }
125 /// Return true if browser should runs in standalone mode
126 bool IsStandalone() const { return fStandalone; }
127
128 /// set window url options
129 RWebDisplayArgs &SetUrlOpt(const std::string &opt) { fUrlOpt = opt; return *this; }
130 /// returns window url options
131 const std::string &GetUrlOpt() const { return fUrlOpt; }
132
133 /// append extra url options, add "&" as separator if required
134 void AppendUrlOpt(const std::string &opt);
135
136 /// returns window url with append options
137 std::string GetFullUrl() const;
138
139 /// set batch mode
140 void SetBatchMode(bool on = true) { fBatchMode = on; }
141 /// returns batch mode
142 bool IsBatchMode() const { return fBatchMode; }
143
144 /// set headless mode
145 void SetHeadless(bool on = true) { fHeadless = on; }
146 /// returns headless mode
147 bool IsHeadless() const { return fHeadless; }
148
149 /// set preferable web window width
150 RWebDisplayArgs &SetWidth(int w = 0) { fWidth = w; return *this; }
151 /// set preferable web window height
152 RWebDisplayArgs &SetHeight(int h = 0) { fHeight = h; return *this; }
153 RWebDisplayArgs &SetSize(int w, int h) { fWidth = w; fHeight = h; return *this; }
154
155 /// set preferable web window x position, negative is default
156 RWebDisplayArgs &SetX(int x = -1) { fX = x; return *this; }
157 /// set preferable web window y position, negative is default
158 RWebDisplayArgs &SetY(int y = -1) { fY = y; return *this; }
159 RWebDisplayArgs &SetPos(int x = -1, int y = -1) { fX = x; fY = y; return *this; }
160
161 /// returns preferable web window width
162 int GetWidth() const { return fWidth; }
163 /// returns preferable web window height
164 int GetHeight() const { return fHeight; }
165 /// set preferable web window x position
166 int GetX() const { return fX; }
167 /// set preferable web window y position
168 int GetY() const { return fY; }
169
170 void SetExtraArgs(const std::string &args) { fExtraArgs = args; }
171 const std::string &GetExtraArgs() const { return fExtraArgs; }
172
173 void SetRedirectOutput(const std::string &fname = "") { fRedirectOutput = fname; }
174 const std::string &GetRedirectOutput() const { return fRedirectOutput; }
175
176 /// set custom executable to start web browser
177 void SetCustomExec(const std::string &exec);
178 /// returns custom executable to start web browser
179 std::string GetCustomExec() const;
180
181 /// set http server instance, used for window display
182 void SetHttpServer(THttpServer *serv) { fServer = serv; }
183 /// returns http server instance, used for window display
184 THttpServer *GetHttpServer() const { return fServer; }
185
186 /// [internal] set web-driver data, used to start window
187 void SetDriverData(void *data) { fDriverData = data; }
188 /// [internal] returns web-driver data, used to start window
189 void *GetDriverData() const { return fDriverData; }
190
191 static std::string GetQt5EmbedQualifier(const void *qparent, const std::string &urlopt = "");
192};
193
194}
195}
196
197#endif
#define h(i)
Definition: RSha256.hxx:106
include TDocParser_001 C image html pict1_TDocParser_001 png width
Definition: TDocParser.cxx:121
Holds different arguments for starting browser with RWebDisplayHandle::Display() method.
std::string GetBrowserName() const
Returns configured browser name.
std::string fPageContent
! HTML page content
bool IsSupportHeadless() const
returns true if browser supports headless mode
void * fDriverData
! special data delivered to driver, can be used for QWebEngine
bool IsHeadless() const
returns headless mode
RWebDisplayArgs & SetPageContent(const std::string &cont)
set window url
void SetExtraArgs(const std::string &args)
const std::string & GetUrlOpt() const
returns window url options
RWebDisplayArgs & SetUrl(const std::string &url)
set window url
bool IsBatchMode() const
returns batch mode
bool SetPosAsStr(const std::string &str)
Set position of web browser window as string like "100,100".
std::string fUrl
! URL to display
RWebDisplayArgs & SetPos(int x=-1, int y=-1)
static std::string GetQt5EmbedQualifier(const void *qparent, const std::string &urlopt="")
returns string which can be used as argument in RWebWindow::Show() method to display web window in pr...
void SetBatchMode(bool on=true)
set batch mode
int GetHeight() const
returns preferable web window height
const std::string & GetWidgetKind() const
returns widget kind
void SetHeadless(bool on=true)
set headless mode
int fMasterChannel
! used master channel
void SetMasterWindow(std::shared_ptr< RWebWindow > master, int channel=-1)
Assign window and channel id where other window will be embed.
void SetHttpServer(THttpServer *serv)
set http server instance, used for window display
EBrowserKind GetBrowserKind() const
returns configured browser kind, see EBrowserKind for supported values
void SetCustomExec(const std::string &exec)
set custom executable to start web browser
const std::string & GetExtraArgs() const
bool fHeadless
! is browser runs in headless mode
RWebDisplayArgs & SetBrowserKind(EBrowserKind kind)
set browser kind, see EBrowserKind for allowed values
int fX
! custom window x position, negative is default
std::shared_ptr< RWebWindow > fMaster
! master window
void AppendUrlOpt(const std::string &opt)
append extra url options, add "&" as separator if required
void SetStandalone(bool on=true)
Set standalone mode for running browser, default on When disabled, normal browser window (or just tab...
std::string GetFullUrl() const
returns window url with append options
THttpServer * fServer
! http server which handle all requests
std::string fWidgetKind
! widget kind, used to identify that will be displayed in the web window
RWebDisplayArgs & SetBrowserKind(const std::string &kind)
Set browser kind as string argument Recognized values: chrome - use Google Chrome web browser,...
std::string fExec
! string to run browser, used with kCustom type
THttpServer * GetHttpServer() const
returns http server instance, used for window display
std::string GetCustomExec() const
returns custom executable to start web browser
bool IsStandalone() const
Return true if browser should runs in standalone mode.
std::string fUrlOpt
! extra URL options, which are append to window URL
RWebDisplayArgs & SetX(int x=-1)
set preferable web window x position, negative is default
bool IsLocalDisplay() const
returns true if local display like CEF or Qt5 QWebEngine should be used
const std::string & GetPageContent() const
returns window url
int fHeight
! custom window height, when not specified - used RWebWindow geometry
RWebDisplayArgs & SetY(int y=-1)
set preferable web window y position, negative is default
void SetRedirectOutput(const std::string &fname="")
@ kFirefox
Mozilla Firefox browser.
@ kCEF
Chromium Embedded Framework - local display with CEF libs.
@ kQt6
Qt6 QWebEngine libraries - Chromium code packed in qt6.
@ kCustom
custom web browser, execution string should be provided
@ kNative
either Chrome or Firefox - both support major functionality
@ kEmbedded
window will be embedded into other, no extra browser need to be started
@ kLocal
either CEF or Qt5 - both runs on local display without real http server
@ kStandard
standard system web browser, not recognized by ROOT, without batch mode
@ kQt5
Qt5 QWebEngine libraries - Chromium code packed in qt5.
void * GetDriverData() const
[internal] returns web-driver data, used to start window
RWebDisplayArgs & SetHeight(int h=0)
set preferable web window height
RWebDisplayArgs & SetUrlOpt(const std::string &opt)
set window url options
const std::string & GetRedirectOutput() const
void SetDriverData(void *data)
[internal] set web-driver data, used to start window
RWebDisplayArgs & SetWidgetKind(const std::string &kind)
set widget kind
RWebDisplayArgs & SetSize(int w, int h)
const std::string & GetUrl() const
returns window url
bool fBatchMode
! is browser runs in batch mode
int fY
! custom window y position, negative is default
bool SetSizeAsStr(const std::string &str)
Set size of web browser window as string like "800x600".
int fWidth
! custom window width, when not specified - used RWebWindow geometry
EBrowserKind fKind
! id of web browser used for display
std::string fExtraArgs
! extra arguments which will be append to exec string
std::string fRedirectOutput
! filename where browser output should be redirected
int GetY() const
set preferable web window y position
int GetX() const
set preferable web window x position
int GetWidth() const
returns preferable web window width
RWebDisplayArgs & SetWidth(int w=0)
set preferable web window width
bool fStandalone
! indicates if browser should run isolated from other browser instances
RWebDisplayArgs()
Default constructor - browser kind configured from gROOT->GetWebDisplay()
Represents web window, which can be shown in web browser or any other supported environment.
Definition: RWebWindow.hxx:53
Double_t y[n]
Definition: legend1.C:17
Double_t x[n]
Definition: legend1.C:17
RLogChannel & WebGUILog()
Log channel for WebGUI diagnostics.
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...