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 bool fHeadless{false}; ///<! is browser runs in headless mode
50 bool fStandalone{true}; ///<! indicates if browser should run isolated from other browser instances
51 THttpServer *fServer{nullptr}; ///<! http server which handle all requests
52 int fWidth{0}; ///<! custom window width, when not specified - used RWebWindow geometry
53 int fHeight{0}; ///<! custom window height, when not specified - used RWebWindow geometry
54 int fX{-1}; ///<! custom window x position, negative is default
55 int fY{-1}; ///<! custom window y position, negative is default
56 std::string fUrlOpt; ///<! extra URL options, which are append to window URL
57 std::string fExec; ///<! string to run browser, used with kCustom type
58 void *fDriverData{nullptr}; ///<! special data delivered to driver, can be used for QWebEngine
59
60 std::shared_ptr<RWebWindow> fMaster; ///<! master window
61 int fMasterChannel{-1}; ///<! used master channel
62
63public:
65
66 RWebDisplayArgs(const std::string &browser);
67
68 RWebDisplayArgs(const char *browser);
69
70 RWebDisplayArgs(int width, int height, int x = -1, int y = -1, const std::string &browser = "");
71
72 RWebDisplayArgs(std::shared_ptr<RWebWindow> master, int channel = -1);
73
74 virtual ~RWebDisplayArgs();
75
76 RWebDisplayArgs &SetBrowserKind(const std::string &kind);
77 /// set browser kind, see EBrowserKind for allowed values
78 RWebDisplayArgs &SetBrowserKind(EBrowserKind kind) { fKind = kind; return *this; }
79 /// returns configured browser kind, see EBrowserKind for supported values
80 EBrowserKind GetBrowserKind() const { return fKind; }
81 std::string GetBrowserName() const;
82
83 void SetMasterWindow(std::shared_ptr<RWebWindow> master, int channel = -1);
84
85 /// returns true if local display like CEF or Qt5 QWebEngine should be used
86 bool IsLocalDisplay() const
87 {
88 return (GetBrowserKind() == kLocal) || (GetBrowserKind() == kCEF) || (GetBrowserKind() == kQt5);
89 }
90
91 /// returns true if browser supports headless mode
92 bool IsSupportHeadless() const
93 {
94 return (GetBrowserKind() == kNative) || (GetBrowserKind() == kFirefox) || (GetBrowserKind() == kChrome);
95 }
96
97 /// set window url
98 RWebDisplayArgs &SetUrl(const std::string &url) { fUrl = url; return *this; }
99 /// returns window url
100 std::string GetUrl() const { return fUrl; }
101
102 /// Set standalone mode for running browser, default on
103 /// When disabled, normal browser window (or just tab) will be started
104 void SetStandalone(bool on = true) { fStandalone = on; }
105 /// Return true if browser should runs in standalone mode
106 bool IsStandalone() const { return fStandalone; }
107
108 /// set window url options
109 RWebDisplayArgs &SetUrlOpt(const std::string &opt) { fUrlOpt = opt; return *this; }
110 /// returns window url options
111 std::string GetUrlOpt() const { return fUrlOpt; }
112
113 /// append extra url options, add "&" as separator if required
114 void AppendUrlOpt(const std::string &opt);
115
116 /// returns window url with append options
117 std::string GetFullUrl() const;
118
119 /// set headless mode
120 void SetHeadless(bool on = true) { fHeadless = on; }
121 /// returns headless mode
122 bool IsHeadless() const { return fHeadless; }
123
124 /// set preferable web window width
125 RWebDisplayArgs &SetWidth(int w = 0) { fWidth = w; return *this; }
126 /// set preferable web window height
127 RWebDisplayArgs &SetHeight(int h = 0) { fHeight = h; return *this; }
128 RWebDisplayArgs &SetSize(int w, int h) { fWidth = w; fHeight = h; return *this; }
129
130 /// set preferable web window x position, negative is default
131 RWebDisplayArgs &SetX(int x = -1) { fX = x; return *this; }
132 /// set preferable web window y position, negative is default
133 RWebDisplayArgs &SetY(int y = -1) { fY = y; return *this; }
134 RWebDisplayArgs &SetPos(int x = -1, int y = -1) { fX = x; fY = y; return *this; }
135
136 /// returns preferable web window width
137 int GetWidth() const { return fWidth; }
138 /// returns preferable web window height
139 int GetHeight() const { return fHeight; }
140 /// set preferable web window x position
141 int GetX() const { return fX; }
142 /// set preferable web window y position
143 int GetY() const { return fY; }
144
145 /// set custom executable to start web browser
146 void SetCustomExec(const std::string &exec);
147 /// returns custom executable to start web browser
148 std::string GetCustomExec() const;
149
150 /// set http server instance, used for window display
151 void SetHttpServer(THttpServer *serv) { fServer = serv; }
152 /// returns http server instance, used for window display
153 THttpServer *GetHttpServer() const { return fServer; }
154
155 /// [internal] set web-driver data, used to start window
156 void SetDriverData(void *data) { fDriverData = data; }
157 /// [internal] returns web-driver data, used to start window
158 void *GetDriverData() const { return fDriverData; }
159};
160
161}
162}
163
164#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
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
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
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
@ 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
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()
int fWidth
! custom window width, when not specified - used RWebWindow geometry
EBrowserKind fKind
! id of web browser used for display
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
VSD Structures.
Definition: StringConv.hxx:21