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.
15 #include "support/std_string.h"
19 /** Launch a file dialog and return the chosen file.
20 filename: a suggested filename.
21 title: the title of the dialog.
23 dir1 = (name, dir), dir2 = (name, dir): extra buttons on the dialog.
26 browseFile(string const & filename,
28 string const & pattern,
30 std::pair<string,string> const & dir1 =
31 std::make_pair(string(), string()),
32 std::pair<string,string> const & dir2 =
33 std::make_pair(string(), string()));
36 /* Wrapper around browseFile which tries to provide a filename
37 relative to relpath. If the relative path is of the form "foo.txt"
38 or "bar/foo.txt", then it is returned as relative. OTOH, if it is
39 of the form "../baz/foo.txt", an absolute path is returned. This is
40 intended to be useful for insets which encapsulate files/
43 browseRelFile(string const & filename,
44 string const & refpath,
46 string const & pattern,
48 std::pair<string,string> const & dir1 =
49 std::make_pair(string(), string()),
50 std::pair<string,string> const & dir2 =
51 std::make_pair(string(), string()));
54 /** Launch a file dialog and return the chosen directory.
55 pathname: a suggested pathname.
56 title: the title of the dialog.
57 dir1 = (name, dir), dir2 = (name, dir): extra buttons on the dialog.
60 browseDir(string const & pathname,
62 std::pair<string,string> const & dir1 =
63 std::make_pair(string(), string()),
64 std::pair<string,string> const & dir2 =
65 std::make_pair(string(), string()));
68 /// Returns a vector of units that can be used to create a valid LaTeX length.
69 std::vector<string> const getLatexUnits();
72 /** Functions to extract vectors of the first and second elems from a
80 typedef typename Pair::first_type first_type;
81 first_type const & operator()(Pair const & p) { return p.first; }
86 typedef typename Pair::second_type second_type;
87 second_type const & operator()(Pair const & p) { return p.second; }
94 std::vector<typename Pair::first_type> const
95 getFirst(std::vector<Pair> const & pr)
97 std::vector<typename Pair::first_type> tmp(pr.size());
98 std::transform(pr.begin(), pr.end(), tmp.begin(),
99 detail::firster<Pair>());
105 std::vector<typename Pair::second_type> const
106 getSecond(std::vector<Pair> const & pr)
108 std::vector<typename Pair::second_type> tmp(pr.size());
109 std::transform(pr.begin(), pr.end(), tmp.begin(),
110 detail::seconder<Pair>());
115 #endif // HELPERFUNCS_H