Logo ROOT  
Reference Guide
RFileDialog.hxx
Go to the documentation of this file.
1// Author: Sergey Linev <S.Linev@gsi.de>
2// Date: 2019-10-31
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_RFileDialog
14#define ROOT7_RFileDialog
15
16#include <ROOT/RWebWindow.hxx>
17#include <ROOT/RBrowserData.hxx>
18
19#include <vector>
20#include <memory>
21#include <stdint.h>
22
23namespace ROOT {
24namespace Experimental {
25
26/** \class ROOT::Experimental::RFileDialog
27\ingroup rbrowser
28Initial message send to client to configure layout
29*/
30
31/// function signature for connect/disconnect call-backs
32/// argument is connection id
33using RFileDialogCallback_t = std::function<void(const std::string &)>;
34
35
36/** Web-based FileDialog */
37
39public:
40
45 };
46
47protected:
48
49 EDialogTypes fKind{kOpenFile}; ///<! dialog kind OpenFile, SaveAs, NewFile
50 std::string fTitle; ///<! title, when not specified default will be used
51 RBrowserData fBrowsable; ///<! central browsing element
52
53 std::shared_ptr<RWebWindow> fWebWindow; ///<! web window for file dialog
54
55 bool fDidSelect{false}; ///<! true when dialog is selected or closed
56 std::string fSelectedFilter; ///<! name of selected filter
57 std::vector<std::string> fNameFilters; ///<! name filters
58 std::string fSelect; ///<! result of file selection
59 RFileDialogCallback_t fCallback; ///<! function receiving result, called once
60
61 static std::string TypeAsString(EDialogTypes kind);
62
63 void SendInitMsg(unsigned connid);
64 void SendChPathMsg(unsigned connid);
65
66 void ProcessMsg(unsigned connid, const std::string &arg);
67
68 void InvokeCallBack();
69
70 std::string GetRegexp(const std::string &name) const;
71
72 static std::string Dialog(EDialogTypes kind, const std::string &title, const std::string &fname);
73
74public:
75
76 RFileDialog(EDialogTypes kind = kOpenFile, const std::string &title = "", const std::string &fname = "");
77 virtual ~RFileDialog();
78
79 const EDialogTypes &GetType() const { return fKind; }
80
82
83 /** Set array of name filters like "Text files (*.txt)", "Any files (*)", "Image files (*png *.jpg)"
84 * Should be specified before starting dialog */
85 void SetNameFilters(const std::vector<std::string> &arr) { fNameFilters = arr; }
86 /** Returns array of name filters*/
87 const auto &GetNameFilters() const { return fNameFilters; }
88
89 void SetSelectedFilter(const std::string &name);
90 std::string GetSelectedFilter() const;
91
92 void Show(const RWebDisplayArgs &args = "");
93 void Hide();
94
95 bool IsCompleted() const { return fDidSelect; }
96 const std::string &GetFileName() const { return fSelect; }
97
98 static std::string OpenFile(const std::string &title = "", const std::string &fname = "");
99 static std::string SaveAs(const std::string &title = "", const std::string &fname = "");
100 static std::string NewFile(const std::string &title = "", const std::string &fname = "");
101
102 static std::shared_ptr<RFileDialog> Embedded(const std::shared_ptr<RWebWindow> &window, const std::string &args);
103
104};
105
106} // namespace Experimental
107} // namespace ROOT
108
109#endif
typedef void(GLAPIENTRYP _GLUfuncptr)(void)
char name[80]
Definition: TGX11.cxx:110
Way to browse (hopefully) everything in ROOT.
Web-based FileDialog.
Definition: RFileDialog.hxx:38
const auto & GetNameFilters() const
Returns array of name filters.
Definition: RFileDialog.hxx:87
std::vector< std::string > fNameFilters
! name filters
Definition: RFileDialog.hxx:57
static std::string Dialog(EDialogTypes kind, const std::string &title, const std::string &fname)
Start specified dialog type.
EDialogTypes fKind
! dialog kind OpenFile, SaveAs, NewFile
Definition: RFileDialog.hxx:49
void SetNameFilters(const std::vector< std::string > &arr)
Set array of name filters like "Text files (*.txt)", "Any files (*)", "Image files (*png *....
Definition: RFileDialog.hxx:85
bool fDidSelect
! true when dialog is selected or closed
Definition: RFileDialog.hxx:55
void Show(const RWebDisplayArgs &args="")
Show or update RFileDialog in web window If web window already started - just refresh it like "reload...
void InvokeCallBack()
Invoke specified callback.
std::shared_ptr< RWebWindow > fWebWindow
! web window for file dialog
Definition: RFileDialog.hxx:53
static std::string SaveAs(const std::string &title="", const std::string &fname="")
Start SaveAs dialog.
std::string GetSelectedFilter() const
Returns selected filter Can differ from specified value - if it does not match to existing entry in N...
const EDialogTypes & GetType() const
Definition: RFileDialog.hxx:79
RBrowserData fBrowsable
! central browsing element
Definition: RFileDialog.hxx:51
void ProcessMsg(unsigned connid, const std::string &arg)
Process received data from client.
static std::shared_ptr< RFileDialog > Embedded(const std::shared_ptr< RWebWindow > &window, const std::string &args)
Create dialog instance to use as embedded dialog inside other widget Embedded dialog started on the c...
static std::string OpenFile(const std::string &title="", const std::string &fname="")
Start OpenFile dialog.
std::string fSelectedFilter
! name of selected filter
Definition: RFileDialog.hxx:56
const std::string & GetFileName() const
Definition: RFileDialog.hxx:96
void Hide()
Hide ROOT Browser.
std::string fSelect
! result of file selection
Definition: RFileDialog.hxx:58
std::string GetRegexp(const std::string &name) const
Returns regexp for selected filter String should have form "Filter name (*.ext1 *....
void SendChPathMsg(unsigned connid)
Sends new data after change current directory.
std::string fTitle
! title, when not specified default will be used
Definition: RFileDialog.hxx:50
RFileDialogCallback_t fCallback
! function receiving result, called once
Definition: RFileDialog.hxx:59
static std::string TypeAsString(EDialogTypes kind)
Returns dialog type as string String value used for configuring JS-side.
static std::string NewFile(const std::string &title="", const std::string &fname="")
Start NewFile dialog.
void SetSelectedFilter(const std::string &name)
Configure selected filter Has to be one of the string from NameFilters entry.
RFileDialog(EDialogTypes kind=kOpenFile, const std::string &title="", const std::string &fname="")
constructor When title not specified, default will be used
Definition: RFileDialog.cxx:43
void SetCallback(RFileDialogCallback_t callback)
Assign callback. If file was already selected, immediately call it.
Definition: RFileDialog.cxx:99
void SendInitMsg(unsigned connid)
Sends initial message to the client.
virtual ~RFileDialog()
destructor
Definition: RFileDialog.cxx:90
Holds different arguments for starting browser with RWebDisplayHandle::Display() method.
std::function< void(const std::string &)> RFileDialogCallback_t
function signature for connect/disconnect call-backs argument is connection id
Definition: RFileDialog.hxx:33
void function(const Char_t *name_, T fun, const Char_t *docstring=0)
Definition: RExports.h:152
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...