Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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 kOff, ///< disable web display, do not start any browser
46 kCustom ///< custom web browser, execution string should be provided
47 };
48
49protected:
50 EBrowserKind fKind{kNative}; ///<! id of web browser used for display
51 std::string fUrl; ///<! URL to display
52 std::string fExtraArgs; ///<! extra arguments which will be append to exec string
53 std::string fPageContent; ///<! HTML page content
54 std::string fRedirectOutput; ///<! filename where browser output should be redirected
55 std::string fWidgetKind; ///<! widget kind, used to identify that will be displayed in the web window
56 bool fBatchMode{false}; ///<! is browser runs in batch mode
57 bool fHeadless{false}; ///<! is browser runs in headless mode
58 bool fStandalone{true}; ///<! indicates if browser should run isolated from other browser instances
59 THttpServer *fServer{nullptr}; ///<! http server which handle all requests
60 int fWidth{0}; ///<! custom window width, when not specified - used RWebWindow geometry
61 int fHeight{0}; ///<! custom window height, when not specified - used RWebWindow geometry
62 int fX{-1}; ///<! custom window x position, negative is default
63 int fY{-1}; ///<! custom window y position, negative is default
64 std::string fUrlOpt; ///<! extra URL options, which are append to window URL
65 std::string fExec; ///<! string to run browser, used with kCustom type
66 void *fDriverData{nullptr}; ///<! special data delivered to driver, can be used for QWebEngine
67
68 std::shared_ptr<RWebWindow> fMaster; ///<! master window
69 int fMasterChannel{-1}; ///<! used master channel
70
71 bool SetSizeAsStr(const std::string &str);
72 bool SetPosAsStr(const std::string &str);
73
74public:
76
77 RWebDisplayArgs(const std::string &browser);
78
79 RWebDisplayArgs(const char *browser);
80
81 RWebDisplayArgs(int width, int height, int x = -1, int y = -1, const std::string &browser = "");
82
83 RWebDisplayArgs(std::shared_ptr<RWebWindow> master, int channel = -1);
84
86
87 RWebDisplayArgs &SetBrowserKind(const std::string &kind);
88 /// set browser kind, see EBrowserKind for allowed values
89 RWebDisplayArgs &SetBrowserKind(EBrowserKind kind) { fKind = kind; return *this; }
90 /// returns configured browser kind, see EBrowserKind for supported values
91 EBrowserKind GetBrowserKind() const { return fKind; }
92 std::string GetBrowserName() const;
93
94 void SetMasterWindow(std::shared_ptr<RWebWindow> master, int channel = -1);
95
96 /// returns true if local display like CEF or Qt5 QWebEngine should be used
97 bool IsLocalDisplay() const
98 {
99 return (GetBrowserKind() == kLocal) || (GetBrowserKind() == kCEF) || (GetBrowserKind() == kQt5) || (GetBrowserKind() == kQt6);
100 }
101
102 /// returns true if browser supports headless mode
103 bool IsSupportHeadless() const
104 {
105 return (GetBrowserKind() == kNative) || (GetBrowserKind() == kChrome) || (GetBrowserKind() == kFirefox) || (GetBrowserKind() == kCEF) || (GetBrowserKind() == kQt5) || (GetBrowserKind() == kQt6);
106 }
107
108 /// set window url
109 RWebDisplayArgs &SetUrl(const std::string &url) { fUrl = url; return *this; }
110 /// returns window url
111 const std::string &GetUrl() const { return fUrl; }
112
113 /// set widget kind
114 RWebDisplayArgs &SetWidgetKind(const std::string &kind) { fWidgetKind = kind; return *this; }
115 /// returns widget kind
116 const std::string &GetWidgetKind() const { return fWidgetKind; }
117
118 /// set window url
119 RWebDisplayArgs &SetPageContent(const std::string &cont) { fPageContent = cont; return *this; }
120 /// returns window url
121 const std::string &GetPageContent() const { return fPageContent; }
122
123 /// Set standalone mode for running browser, default on
124 /// When disabled, normal browser window (or just tab) will be started
125 void SetStandalone(bool on = true) { fStandalone = on; }
126 /// Return true if browser should runs in standalone mode
127 bool IsStandalone() const { return fStandalone; }
128
129 /// set window url options
130 RWebDisplayArgs &SetUrlOpt(const std::string &opt) { fUrlOpt = opt; return *this; }
131 /// returns window url options
132 const std::string &GetUrlOpt() const { return fUrlOpt; }
133
134 /// append extra url options, add "&" as separator if required
135 void AppendUrlOpt(const std::string &opt);
136
137 /// returns window url with append options
138 std::string GetFullUrl() const;
139
140 /// set batch mode
141 void SetBatchMode(bool on = true) { fBatchMode = on; }
142 /// returns batch mode
143 bool IsBatchMode() const { return fBatchMode; }
144
145 /// set headless mode
146 void SetHeadless(bool on = true) { fHeadless = on; }
147 /// returns headless mode
148 bool IsHeadless() const { return fHeadless; }
149
150 /// set preferable web window width
151 RWebDisplayArgs &SetWidth(int w = 0) { fWidth = w; return *this; }
152 /// set preferable web window height
153 RWebDisplayArgs &SetHeight(int h = 0) { fHeight = h; return *this; }
154 /// set preferable web window width and height
155 RWebDisplayArgs &SetSize(int w, int h) { fWidth = w; fHeight = h; return *this; }
156
157 /// set preferable web window x position, negative is default
158 RWebDisplayArgs &SetX(int x = -1) { fX = x; return *this; }
159 /// set preferable web window y position, negative is default
160 RWebDisplayArgs &SetY(int y = -1) { fY = y; return *this; }
161 /// set preferable web window x and y position, negative is default
162 RWebDisplayArgs &SetPos(int x = -1, int y = -1) { fX = x; fY = y; return *this; }
163
164 /// returns preferable web window width
165 int GetWidth() const { return fWidth; }
166 /// returns preferable web window height
167 int GetHeight() const { return fHeight; }
168 /// set preferable web window x position
169 int GetX() const { return fX; }
170 /// set preferable web window y position
171 int GetY() const { return fY; }
172
173 /// set extra command line arguments for starting web browser command
174 void SetExtraArgs(const std::string &args) { fExtraArgs = args; }
175 /// get extra command line arguments for starting web browser command
176 const std::string &GetExtraArgs() const { return fExtraArgs; }
177
178 /// specify file name to which web browser output should be redirected
179 void SetRedirectOutput(const std::string &fname = "") { fRedirectOutput = fname; }
180 /// get file name to which web browser output should be redirected
181 const std::string &GetRedirectOutput() const { return fRedirectOutput; }
182
183 /// set custom executable to start web browser
184 void SetCustomExec(const std::string &exec);
185 /// returns custom executable to start web browser
186 std::string GetCustomExec() const;
187
188 /// set http server instance, used for window display
189 void SetHttpServer(THttpServer *serv) { fServer = serv; }
190 /// returns http server instance, used for window display
191 THttpServer *GetHttpServer() const { return fServer; }
192
193 /// [internal] set web-driver data, used to start window
194 void SetDriverData(void *data) { fDriverData = data; }
195 /// [internal] returns web-driver data, used to start window
196 void *GetDriverData() const { return fDriverData; }
197
198 static std::string GetQt5EmbedQualifier(const void *qparent, const std::string &urlopt = "");
199};
200
201}
202}
203
204#endif
#define h(i)
Definition RSha256.hxx:106
include TDocParser_001 C image html pict1_TDocParser_001 png width
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
virtual ~RWebDisplayArgs()
Destructor must be defined in source code to correctly call RWebWindow destructor.
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)
set extra command line arguments for starting web browser command
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)
set preferable web window x and y position, negative is default
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
get extra command line arguments for starting web browser command
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="")
specify file name to which web browser output should be redirected
@ 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
@ kOff
disable web display, do not start any browser
@ 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
get file name to which web browser output should be redirected
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)
set preferable web window width and height
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.
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...