3 * \file frontend_helpers.h
4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
7 * \author Angus Leeming
10 * Full author contact details are available in file CREDITS.
13 #ifndef FRONTEND_HELPERS_H
14 #define FRONTEND_HELPERS_H
17 #include "support/docstring.h"
22 #include <boost/bind.hpp>
31 /** Functions of use to the character GUI controller and view */
50 typedef std::pair<docstring, Font::FONT_FAMILY> FamilyPair;
52 typedef std::pair<docstring, Font::FONT_SERIES> SeriesPair;
54 typedef std::pair<docstring, Font::FONT_SHAPE> ShapePair;
56 typedef std::pair<docstring, Font::FONT_SIZE> SizePair;
58 typedef std::pair<docstring, FONT_STATE> BarPair;
60 typedef std::pair<docstring, Color_color> ColorPair;
63 std::vector<FamilyPair> const getFamilyData();
65 std::vector<SeriesPair> const getSeriesData();
67 std::vector<ShapePair> const getShapeData();
69 std::vector<SizePair> const getSizeData();
71 std::vector<BarPair> const getBarData();
73 std::vector<ColorPair> const getColorData();
77 typedef std::pair<docstring, std::string> LanguagePair;
79 /** If the caller is the character dialog, add "No change" and "Reset"
82 std::vector<LanguagePair> const getLanguageData(bool character_dlg);
83 /// sort colors for the gui
84 std::vector<Color_color> const getSortedColors(std::vector<Color_color> colors);
86 } // namespace frontend
89 namespace support { class FileFilterList; }
94 /** Launch a file dialog and return the chosen file.
95 filename: a suggested filename.
96 title: the title of the dialog.
98 dir1 = (name, dir), dir2 = (name, dir): extra buttons on the dialog.
101 browseFile(docstring const & filename,
102 docstring const & title,
103 support::FileFilterList const & filters,
105 std::pair<docstring, docstring> const & dir1 =
106 std::make_pair(docstring(), docstring()),
107 std::pair<docstring, docstring> const & dir2 =
108 std::make_pair(docstring(), docstring()));
111 /** Wrapper around browseFile which tries to provide a filename
112 relative to relpath. If the relative path is of the form "foo.txt"
113 or "bar/foo.txt", then it is returned as relative. OTOH, if it is
114 of the form "../baz/foo.txt", an absolute path is returned. This is
115 intended to be useful for insets which encapsulate files/
118 browseRelFile(docstring const & filename,
119 docstring const & refpath,
120 docstring const & title,
121 support::FileFilterList const & filters,
123 std::pair<docstring, docstring> const & dir1 =
124 std::make_pair(docstring(), docstring()),
125 std::pair<docstring, docstring> const & dir2 =
126 std::make_pair(docstring(), docstring()));
129 /** Wrapper around browseFile which tries to provide a filename
130 * relative to the user or system directory. The dir, name and ext
131 * parameters have the same meaning as in the
132 * support::LibFileSearch function.
135 browseLibFile(docstring const & dir,
136 docstring const & name,
137 docstring const & ext,
138 docstring const & title,
139 support::FileFilterList const & filters);
142 /** Launch a file dialog and return the chosen directory.
143 pathname: a suggested pathname.
144 title: the title of the dialog.
145 dir1 = (name, dir), dir2 = (name, dir): extra buttons on the dialog.
148 browseDir(docstring const & pathname,
149 docstring const & title,
150 std::pair<docstring, docstring> const & dir1 =
151 std::make_pair(docstring(), docstring()),
152 std::pair<docstring, docstring> const & dir2 =
153 std::make_pair(docstring(), docstring()));
156 /// Returns a vector of units that can be used to create a valid LaTeX length.
157 std::vector<docstring> const getLatexUnits();
160 /** Functions to extract vectors of the first and second elems from a
164 std::vector<typename Pair::first_type> const
165 getFirst(std::vector<Pair> const & pr)
167 std::vector<typename Pair::first_type> tmp(pr.size());
168 std::transform(pr.begin(), pr.end(), tmp.begin(),
169 boost::bind(&Pair::first, _1));
174 std::vector<typename Pair::second_type> const
175 getSecond(std::vector<Pair> const & pr)
177 std::vector<typename Pair::second_type> tmp(pr.size());
178 std::transform(pr.begin(), pr.end(), tmp.begin(),
179 boost::bind(&Pair::second, _1));
183 /** Build filelists of all availabe bst/cls/sty-files. Done through
184 * kpsewhich and an external script, saved in *Files.lst.
186 void rescanTexStyles();
188 /// rebuild the textree
191 /** Fill \c contents from one of the three texfiles.
192 * Each entry in the file list is returned as a name_with_path
194 void getTexFileList(std::string const & filename, std::vector<std::string> & contents);
196 /// get the options of stylefile
197 std::string const getListOfOptions(std::string const & classname, std::string const & type);
199 /// get a class with full path from the list
200 std::string const getTexFileFromList(std::string const & classname, std::string const & type);
202 } // namespace frontend
205 #endif // FRONTEND_HELPERS_H