]> git.lyx.org Git - lyx.git/blob - src/frontends/gtk/ghelpers.h
enable Font cache only for MacOSX and inline width() for other platform.
[lyx.git] / src / frontends / gtk / ghelpers.h
1 // -*- C++ -*-
2 /**
3  * \file ghelpers.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 John Spray
9  *
10  * Full author contact details are available in file CREDITS.
11  */
12
13 #ifndef GHELPERS_H
14 #define GHELPERS_H
15
16 #include "lengthcommon.h"
17
18 #include <gtkmm.h>
19
20 #include <string>
21 #include <vector>
22
23 class FuncRequest;
24
25 namespace lyx {
26 namespace frontend {
27
28 // Load an icon from GTK icon theme
29 // Return NULL if no suitable icon found
30 Gtk::Image *getGTKIcon(FuncRequest const & func, Gtk::IconSize const & size);
31
32 std::string const getDefaultUnit();
33
34 void unitsComboFromLength(
35         Gtk::ComboBox * combo,
36         Gtk::TreeModelColumn<Glib::ustring> const & stringcol,
37         LyXLength const & len,
38         std::string const & defunit);
39
40 std::vector<std::string> const buildLengthUnitList(bool userelative);
41
42 /** name is the name of the glade file, without path or extension.
43  *  Eg, "aboutlyx", "tableCreate".
44  */
45 std::string const findGladeFile(std::string const & name);
46
47 template<class A>
48 typename std::vector<A>::size_type
49 findPos(std::vector<A> const & vec, A const & val)
50 {
51         typename std::vector<A>::const_iterator it =
52                 std::find(vec.begin(), vec.end(), val);
53         if (it == vec.end())
54                 return 0;
55         return std::distance(vec.begin(), it);
56 }
57
58 } // namespace frontend
59 } // namespace lyx
60
61 #endif // NOT GHELPERS_H