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