File indexing completed on 2025-01-18 10:10:49
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013 #ifndef ROOT7_RWebDisplayArgs
0014 #define ROOT7_RWebDisplayArgs
0015
0016 #include <string>
0017 #include <memory>
0018
0019 class THttpServer;
0020
0021 namespace ROOT {
0022
0023 namespace Experimental {
0024 class RLogChannel;
0025 }
0026
0027
0028 ROOT::Experimental::RLogChannel &WebGUILog();
0029
0030
0031 class RWebWindow;
0032
0033 class RWebDisplayArgs {
0034
0035 friend class RWebWindow;
0036
0037 public:
0038 enum EBrowserKind {
0039 kChrome,
0040 kEdge,
0041 kFirefox,
0042 kNative,
0043 kCEF,
0044 kQt5,
0045 kQt6,
0046 kLocal,
0047 kDefault,
0048 kServer,
0049 kEmbedded,
0050 kOff,
0051 kOn,
0052 kCustom
0053 };
0054
0055 protected:
0056 EBrowserKind fKind{kNative};
0057 std::string fUrl;
0058 std::string fExtraArgs;
0059 std::string fPageContent;
0060 std::string fRedirectOutput;
0061 std::string fWidgetKind;
0062 bool fBatchMode{false};
0063 bool fHeadless{false};
0064 bool fStandalone{true};
0065 THttpServer *fServer{nullptr};
0066 int fWidth{0};
0067 int fHeight{0};
0068 int fX{-1};
0069 int fY{-1};
0070 std::string fUrlOpt;
0071 std::string fExec;
0072 void *fDriverData{nullptr};
0073
0074 std::shared_ptr<RWebWindow> fMaster;
0075 unsigned fMasterConnection{0};
0076 int fMasterChannel{-1};
0077
0078 bool SetSizeAsStr(const std::string &str);
0079 bool SetPosAsStr(const std::string &str);
0080
0081 public:
0082 RWebDisplayArgs();
0083
0084 RWebDisplayArgs(const std::string &browser);
0085
0086 RWebDisplayArgs(const char *browser);
0087
0088 RWebDisplayArgs(int width, int height, int x = -1, int y = -1, const std::string &browser = "");
0089
0090 RWebDisplayArgs(std::shared_ptr<RWebWindow> master, unsigned conndid = 0, int channel = -1);
0091
0092 virtual ~RWebDisplayArgs();
0093
0094 RWebDisplayArgs &SetBrowserKind(const std::string &kind);
0095
0096 RWebDisplayArgs &SetBrowserKind(EBrowserKind kind) { fKind = kind; return *this; }
0097
0098 EBrowserKind GetBrowserKind() const { return fKind; }
0099 std::string GetBrowserName() const;
0100
0101 void SetMasterWindow(std::shared_ptr<RWebWindow> master, unsigned connid = 0, int channel = -1);
0102
0103
0104 bool IsInteractiveBrowser() const
0105 {
0106 return !IsHeadless() &&
0107 ((GetBrowserKind() == kOn) || (GetBrowserKind() == kNative) || (GetBrowserKind() == kChrome) ||
0108 (GetBrowserKind() == kEdge) || (GetBrowserKind() == kFirefox) || (GetBrowserKind() == kDefault) ||
0109 (GetBrowserKind() == kCustom));
0110 }
0111
0112
0113 bool IsLocalDisplay() const
0114 {
0115 return (GetBrowserKind() == kLocal) || (GetBrowserKind() == kCEF) || (GetBrowserKind() == kQt5) || (GetBrowserKind() == kQt6);
0116 }
0117
0118
0119 bool IsSupportHeadless() const
0120 {
0121 return (GetBrowserKind() == kNative) || (GetBrowserKind() == kDefault) || (GetBrowserKind() == kOn) ||
0122 (GetBrowserKind() == kChrome) || (GetBrowserKind() == kEdge) || (GetBrowserKind() == kFirefox) ||
0123 (GetBrowserKind() == kCEF) || (GetBrowserKind() == kQt5) || (GetBrowserKind() == kQt6);
0124 }
0125
0126
0127 RWebDisplayArgs &SetUrl(const std::string &url) { fUrl = url; return *this; }
0128
0129 const std::string &GetUrl() const { return fUrl; }
0130
0131
0132 RWebDisplayArgs &SetWidgetKind(const std::string &kind) { fWidgetKind = kind; return *this; }
0133
0134 const std::string &GetWidgetKind() const { return fWidgetKind; }
0135
0136
0137 RWebDisplayArgs &SetPageContent(const std::string &cont) { fPageContent = cont; return *this; }
0138
0139 const std::string &GetPageContent() const { return fPageContent; }
0140
0141
0142
0143 void SetStandalone(bool on = true) { fStandalone = on; }
0144
0145 bool IsStandalone() const { return fStandalone; }
0146
0147
0148 RWebDisplayArgs &SetUrlOpt(const std::string &opt) { fUrlOpt = opt; return *this; }
0149
0150 const std::string &GetUrlOpt() const { return fUrlOpt; }
0151
0152
0153 void AppendUrlOpt(const std::string &opt);
0154
0155
0156 std::string GetFullUrl() const;
0157
0158
0159 void SetBatchMode(bool on = true) { fBatchMode = on; }
0160
0161 bool IsBatchMode() const { return fBatchMode; }
0162
0163
0164 void SetHeadless(bool on = true) { fHeadless = on; }
0165
0166 bool IsHeadless() const { return fHeadless; }
0167
0168
0169 RWebDisplayArgs &SetWidth(int w = 0) { fWidth = w; return *this; }
0170
0171 RWebDisplayArgs &SetHeight(int h = 0) { fHeight = h; return *this; }
0172
0173 RWebDisplayArgs &SetSize(int w, int h) { fWidth = w; fHeight = h; return *this; }
0174
0175
0176 RWebDisplayArgs &SetX(int x = -1) { fX = x; return *this; }
0177
0178 RWebDisplayArgs &SetY(int y = -1) { fY = y; return *this; }
0179
0180 RWebDisplayArgs &SetPos(int x = -1, int y = -1) { fX = x; fY = y; return *this; }
0181
0182
0183 int GetWidth() const { return fWidth; }
0184
0185 int GetHeight() const { return fHeight; }
0186
0187 int GetX() const { return fX; }
0188
0189 int GetY() const { return fY; }
0190
0191
0192 void SetExtraArgs(const std::string &args) { fExtraArgs = args; }
0193
0194 const std::string &GetExtraArgs() const { return fExtraArgs; }
0195
0196
0197 void SetRedirectOutput(const std::string &fname = "") { fRedirectOutput = fname; }
0198
0199 const std::string &GetRedirectOutput() const { return fRedirectOutput; }
0200
0201
0202 void SetCustomExec(const std::string &exec);
0203
0204 std::string GetCustomExec() const;
0205
0206
0207 void SetHttpServer(THttpServer *serv) { fServer = serv; }
0208
0209 THttpServer *GetHttpServer() const { return fServer; }
0210
0211
0212 void SetDriverData(void *data) { fDriverData = data; }
0213
0214 void *GetDriverData() const { return fDriverData; }
0215
0216 static std::string GetQt5EmbedQualifier(const void *qparent, const std::string &urlopt = "", unsigned qtversion = 0x50000);
0217 };
0218
0219 }
0220
0221 #endif