4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
7 * \author Angus Leeming
9 * Full author contact details are available in file CREDITS
18 #include <utility> // pair
19 #include <vector> // pair
23 /** Launch a file dialog and return the chosen file.
24 filename: a suggested filename.
25 title: the title of the dialog.
27 dir1 = (name, dir), dir2 = (name, dir): extra buttons on the dialog.
30 browseFile(LyXView * lv, string const & filename,
32 string const & pattern,
34 std::pair<string,string> const & dir1 =
35 std::make_pair(string(), string()),
36 std::pair<string,string> const & dir2 =
37 std::make_pair(string(), string()));
40 /* Wrapper around browseFile which tries to provide a filename
41 relative to relpath. If the relative path is of the form "foo.txt"
42 or "bar/foo.txt", then it is returned as relative. OTOH, if it is
43 of the form "../baz/foo.txt", an absolute path is returned. This is
44 intended to be useful for insets which encapsulate files/
47 browseRelFile(LyXView * lv, string const & filename,
48 string const & refpath,
50 string const & pattern,
52 std::pair<string,string> const & dir1 =
53 std::make_pair(string(), string()),
54 std::pair<string,string> const & dir2 =
55 std::make_pair(string(), string()));
58 /** Launch a file dialog and return the chosen directory.
59 pathname: a suggested pathname.
60 title: the title of the dialog.
61 dir1 = (name, dir), dir2 = (name, dir): extra buttons on the dialog.
64 browseDir(LyXView * lv, string const & pathname,
66 std::pair<string,string> const & dir1 =
67 std::make_pair(string(), string()),
68 std::pair<string,string> const & dir2 =
69 std::make_pair(string(), string()));
72 /// Returns a vector of units that can be used to create a valid LaTeX length.
73 std::vector<string> const getLatexUnits();
76 /** Functions to extract vectors of the first and second elems from a
84 typedef typename Pair::first_type first_type;
85 first_type const & operator()(Pair const & p) { return p.first; }
90 typedef typename Pair::second_type second_type;
91 second_type const & operator()(Pair const & p) { return p.second; }
98 std::vector<typename Pair::first_type> const
99 getFirst(std::vector<Pair> const & pr)
101 std::vector<typename Pair::first_type> tmp(pr.size());
102 std::transform(pr.begin(), pr.end(), tmp.begin(),
103 detail::firster<Pair>());
109 std::vector<typename Pair::second_type> const
110 getSecond(std::vector<Pair> const & pr)
112 std::vector<typename Pair::second_type> tmp(pr.size());
113 std::transform(pr.begin(), pr.end(), tmp.begin(),
114 detail::seconder<Pair>());
119 #endif // HELPERFUNCS_H