]> git.lyx.org Git - features.git/blob - src/frontends/controllers/frontend_helpers.h
merge ButtonController and its view (Qt2BC in this case)
[features.git] / src / frontends / controllers / frontend_helpers.h
1 // -*- C++ -*-
2 /**
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.
6  *
7  * \author Angus Leeming
8  * \author Herbert Voß
9  *
10  * Full author contact details are available in file CREDITS.
11  */
12
13 #ifndef FRONTEND_HELPERS_H
14 #define FRONTEND_HELPERS_H
15
16 #include "Font.h"
17 #include "support/docstring.h"
18
19 #include <utility>
20 #include <vector>
21 #include <string>
22
23 class Color_color;
24
25 /** Functions of use to the character GUI controller and view */
26 namespace lyx {
27
28 namespace support { class FileFilterList; }
29
30 namespace frontend {
31
32 ///
33 enum FONT_STATE {
34         ///
35         IGNORE,
36         ///
37         EMPH_TOGGLE,
38         ///
39         UNDERBAR_TOGGLE,
40         ///
41         NOUN_TOGGLE,
42         ///
43         INHERIT
44 };
45
46 ///
47 typedef std::pair<docstring, Font::FONT_FAMILY> FamilyPair;
48 ///
49 typedef std::pair<docstring, Font::FONT_SERIES> SeriesPair;
50 ///
51 typedef std::pair<docstring, Font::FONT_SHAPE>  ShapePair;
52 ///
53 typedef std::pair<docstring, Font::FONT_SIZE>   SizePair;
54 ///
55 typedef std::pair<docstring, FONT_STATE> BarPair;
56 ///
57 typedef std::pair<docstring, Color_color> ColorPair;
58
59 ///
60 std::vector<FamilyPair>   const getFamilyData();
61 ///
62 std::vector<SeriesPair>   const getSeriesData();
63 ///
64 std::vector<ShapePair>    const getShapeData();
65 ///
66 std::vector<SizePair>     const getSizeData();
67 ///
68 std::vector<BarPair>      const getBarData();
69 ///
70 std::vector<ColorPair>    const getColorData();
71
72
73 ///
74 typedef std::pair<docstring, std::string> LanguagePair;
75
76 /** If the caller is the character dialog, add "No change" and "Reset"
77  *  to the vector.
78  */
79 std::vector<LanguagePair> const getLanguageData(bool character_dlg);
80 /// sort colors for the gui
81 std::vector<Color_color> const getSortedColors(std::vector<Color_color> colors);
82
83 /** Launch a file dialog and return the chosen file.
84     filename: a suggested filename.
85     title: the title of the dialog.
86     pattern: *.ps etc.
87     dir1 = (name, dir), dir2 = (name, dir): extra buttons on the dialog.
88 */
89 docstring const
90 browseFile(docstring const & filename,
91            docstring const & title,
92            support::FileFilterList const & filters,
93            bool save = false,
94            std::pair<docstring, docstring> const & dir1 =
95            std::make_pair(docstring(), docstring()),
96            std::pair<docstring, docstring> const & dir2 =
97            std::make_pair(docstring(), docstring()));
98
99
100 /** Wrapper around browseFile which tries to provide a filename
101     relative to relpath.  If the relative path is of the form "foo.txt"
102     or "bar/foo.txt", then it is returned as relative. OTOH, if it is
103     of the form "../baz/foo.txt", an absolute path is returned. This is
104     intended to be useful for insets which encapsulate files/
105 */
106 docstring const
107 browseRelFile(docstring const & filename,
108               docstring const & refpath,
109               docstring const & title,
110               support::FileFilterList const & filters,
111               bool save = false,
112               std::pair<docstring, docstring> const & dir1 =
113               std::make_pair(docstring(), docstring()),
114               std::pair<docstring, docstring> const & dir2 =
115               std::make_pair(docstring(), docstring()));
116
117
118 /** Wrapper around browseFile which tries to provide a filename
119  *  relative to the user or system directory. The dir, name and ext
120  *  parameters have the same meaning as in the
121  *  support::LibFileSearch function.
122  */
123 docstring const
124 browseLibFile(docstring const & dir,
125               docstring const & name,
126               docstring const & ext,
127               docstring const & title,
128               support::FileFilterList const & filters);
129
130
131 /** Launch a file dialog and return the chosen directory.
132     pathname: a suggested pathname.
133     title: the title of the dialog.
134     dir1 = (name, dir), dir2 = (name, dir): extra buttons on the dialog.
135 */
136 docstring const
137 browseDir(docstring const & pathname,
138            docstring const & title,
139            std::pair<docstring, docstring> const & dir1 =
140            std::make_pair(docstring(), docstring()),
141            std::pair<docstring, docstring> const & dir2 =
142            std::make_pair(docstring(), docstring()));
143
144
145 /// Returns a vector of units that can be used to create a valid LaTeX length.
146 std::vector<docstring> const getLatexUnits();
147
148
149 /** Build filelists of all availabe bst/cls/sty-files. Done through
150  *  kpsewhich and an external script, saved in *Files.lst.
151  */
152 void rescanTexStyles();
153
154 /// rebuild the textree
155 void texhash();
156
157 /** Fill \c contents from one of the three texfiles.
158  *  Each entry in the file list is returned as a name_with_path
159  */
160 void getTexFileList(std::string const & filename, std::vector<std::string> & contents);
161
162 /// get the options of stylefile
163 std::string const getListOfOptions(std::string const & classname, std::string const & type);
164
165 /// get a class with full path from the list
166 std::string const getTexFileFromList(std::string const & classname, std::string const & type);
167
168 } // namespace frontend
169 } // namespace lyx
170
171 #endif // FRONTEND_HELPERS_H