4 * See the file COPYING.
6 * \author Angus Leeming
8 * Full author contact details are available in file CREDITS
20 #include <utility> // pair
21 #include <vector> // pair
25 /** Launch a file dialog and return the chosen file.
26 filename: a suggested filename.
27 title: the title of the dialog.
29 dir1 = (name, dir), dir2 = (name, dir): extra buttons on the dialog.
31 string const browseFile(LyXView *lv, string const & filename,
33 string const & pattern,
34 std::pair<string,string> const & dir1 = std::make_pair(string(), string()),
35 std::pair<string,string> const & dir2 = std::make_pair(string(), string()));
38 /* Wrapper around browseFile which tries to provide a filename
39 relative to relpath. If the relative path is of the form "foo.txt"
40 or "bar/foo.txt", then it is returned as relative. OTOH, if it is
41 of the form "../baz/foo.txt", an absolute path is returned. This is
42 intended to be useful for insets which encapsulate files/
44 string const browseRelFile(LyXView *lv, string const & filename,
45 string const & refpath,
47 string const & pattern,
48 std::pair<string,string> const & dir1 = std::make_pair(string(), string()),
49 std::pair<string,string> const & dir2 = std::make_pair(string(), string()));
52 /// Returns a vector of units that can be used to create a valid LaTeX length.
53 std::vector<string> const getLatexUnits();
56 /** Functions to extract vectors of the first and second elems from a
64 typedef typename Pair::first_type first_type;
65 first_type const & operator()(Pair const & p) { return p.first; }
70 typedef typename Pair::second_type second_type;
71 second_type const & operator()(Pair const & p) { return p.second; }
78 std::vector<typename Pair::first_type> const
79 getFirst(std::vector<Pair> const & pr)
81 std::vector<typename Pair::first_type> tmp(pr.size());
82 std::transform(pr.begin(), pr.end(), tmp.begin(),
83 hide::firster<Pair>());
89 std::vector<typename Pair::second_type> const
90 getSecond(std::vector<Pair> const & pr)
92 std::vector<typename Pair::second_type> tmp(pr.size());
93 std::transform(pr.begin(), pr.end(), tmp.begin(),
94 hide::seconder<Pair>());
99 #endif // HELPERFUNCS_H