]> git.lyx.org Git - lyx.git/blob - src/frontends/gtk/ghelpers.h
some tabular fixes for the problems reported by Helge
[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  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #ifndef GHELPERS_H
13 #define GHELPERS_H
14
15 #include "lengthcommon.h"
16
17 #include <gtkmm.h>
18
19 #include <string>
20 #include <vector>
21
22 class FuncRequest;
23
24 namespace lyx {
25 namespace frontend {
26
27 std::string const getLengthFromWidgets(
28         Gtk::Adjustment const & adj,
29         Gtk::ComboBoxText const & combo);
30
31 void setWidgetsFromLength(
32         Gtk::Adjustment & adj,
33         Gtk::ComboBoxText & combo,
34         LyXLength const & length);
35
36 int comboBoxTextSet(Gtk::ComboBoxText & combo, Glib::ustring target);
37
38 void populateUnitCombo(Gtk::ComboBoxText & combo, bool userelative);
39
40 // Get a GTK stockID from a lyx function id.
41 // Return Gtk::Stock::MISSING_IMAGE if no suitable stock found
42 Gtk::BuiltinStockID getGTKStockIcon(FuncRequest const & func);
43
44 std::string const getDefaultUnit();
45
46 void unitsComboFromLength(
47         Gtk::ComboBox * combo,
48         Gtk::TreeModelColumn<Glib::ustring> const & stringcol,
49         LyXLength const & len,
50         std::string const & defunit);
51
52 std::vector<std::string> const buildLengthUnitList(bool userelative);
53
54 /** name is the name of the glade file, without path or extension.
55  *  Eg, "aboutlyx", "tableCreate".
56  */
57 std::string const findGladeFile(std::string const & name);
58
59 template<class A>
60 typename std::vector<A>::size_type
61 findPos(std::vector<A> const & vec, A const & val)
62 {
63         typename std::vector<A>::const_iterator it =
64                 std::find(vec.begin(), vec.end(), val);
65         if (it == vec.end())
66                 return 0;
67         return std::distance(vec.begin(), it);
68 }
69
70 } // namespace frontend
71 } // namespace lyx
72
73 #endif // NOT GHELPERS_H