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
21 #include <utility> // pair
22 #include <vector> // pair
26 /** Launch a file dialog and return the chosen file.
27 filename: a suggested filename.
28 title: the title of the dialog.
30 dir1 = (name, dir), dir2 = (name, dir): extra buttons on the dialog.
33 browseFile(LyXView * lv, string const & filename,
35 string const & pattern,
37 std::pair<string,string> const & dir1 =
38 std::make_pair(string(), string()),
39 std::pair<string,string> const & dir2 =
40 std::make_pair(string(), string()));
43 /* Wrapper around browseFile which tries to provide a filename
44 relative to relpath. If the relative path is of the form "foo.txt"
45 or "bar/foo.txt", then it is returned as relative. OTOH, if it is
46 of the form "../baz/foo.txt", an absolute path is returned. This is
47 intended to be useful for insets which encapsulate files/
50 browseRelFile(LyXView * lv, string const & filename,
51 string const & refpath,
53 string const & pattern,
55 std::pair<string,string> const & dir1 =
56 std::make_pair(string(), string()),
57 std::pair<string,string> const & dir2 =
58 std::make_pair(string(), string()));
61 /** Launch a file dialog and return the chosen directory.
62 pathname: a suggested pathname.
63 title: the title of the dialog.
64 dir1 = (name, dir), dir2 = (name, dir): extra buttons on the dialog.
67 browseDir(LyXView * lv, string const & pathname,
69 std::pair<string,string> const & dir1 =
70 std::make_pair(string(), string()),
71 std::pair<string,string> const & dir2 =
72 std::make_pair(string(), string()));
75 /// Returns a vector of units that can be used to create a valid LaTeX length.
76 std::vector<string> const getLatexUnits();
79 /** Functions to extract vectors of the first and second elems from a
87 typedef typename Pair::first_type first_type;
88 first_type const & operator()(Pair const & p) { return p.first; }
93 typedef typename Pair::second_type second_type;
94 second_type const & operator()(Pair const & p) { return p.second; }
101 std::vector<typename Pair::first_type> const
102 getFirst(std::vector<Pair> const & pr)
104 std::vector<typename Pair::first_type> tmp(pr.size());
105 std::transform(pr.begin(), pr.end(), tmp.begin(),
106 detail::firster<Pair>());
112 std::vector<typename Pair::second_type> const
113 getSecond(std::vector<Pair> const & pr)
115 std::vector<typename Pair::second_type> tmp(pr.size());
116 std::transform(pr.begin(), pr.end(), tmp.begin(),
117 detail::seconder<Pair>());
122 #endif // HELPERFUNCS_H