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.
16 #include "support/std_string.h"
18 #include <utility> // pair
19 #include <vector> // pair
21 /** Launch a file dialog and return the chosen file.
22 filename: a suggested filename.
23 title: the title of the dialog.
25 dir1 = (name, dir), dir2 = (name, dir): extra buttons on the dialog.
28 browseFile(string const & filename,
30 string const & pattern,
32 std::pair<string,string> const & dir1 =
33 std::make_pair(string(), string()),
34 std::pair<string,string> const & dir2 =
35 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/
45 browseRelFile(string const & filename,
46 string const & refpath,
48 string const & pattern,
50 std::pair<string,string> const & dir1 =
51 std::make_pair(string(), string()),
52 std::pair<string,string> const & dir2 =
53 std::make_pair(string(), string()));
56 /** Launch a file dialog and return the chosen directory.
57 pathname: a suggested pathname.
58 title: the title of the dialog.
59 dir1 = (name, dir), dir2 = (name, dir): extra buttons on the dialog.
62 browseDir(string const & pathname,
64 std::pair<string,string> const & dir1 =
65 std::make_pair(string(), string()),
66 std::pair<string,string> const & dir2 =
67 std::make_pair(string(), string()));
70 /// Returns a vector of units that can be used to create a valid LaTeX length.
71 std::vector<string> const getLatexUnits();
74 /** Functions to extract vectors of the first and second elems from a
82 typedef typename Pair::first_type first_type;
83 first_type const & operator()(Pair const & p) { return p.first; }
88 typedef typename Pair::second_type second_type;
89 second_type const & operator()(Pair const & p) { return p.second; }
96 std::vector<typename Pair::first_type> const
97 getFirst(std::vector<Pair> const & pr)
99 std::vector<typename Pair::first_type> tmp(pr.size());
100 std::transform(pr.begin(), pr.end(), tmp.begin(),
101 detail::firster<Pair>());
107 std::vector<typename Pair::second_type> const
108 getSecond(std::vector<Pair> const & pr)
110 std::vector<typename Pair::second_type> tmp(pr.size());
111 std::transform(pr.begin(), pr.end(), tmp.begin(),
112 detail::seconder<Pair>());
117 #endif // HELPERFUNCS_H