]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/qt_helpers.h
enable Font cache only for MacOSX and inline width() for other platform.
[lyx.git] / src / frontends / qt4 / qt_helpers.h
1 // -*- C++ -*-
2 /**
3  * \file qt_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 Dekel Tsur
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #ifndef QTHELPERS_H
13 #define QTHELPERS_H
14
15 #include <utility>
16
17 #include "lyxlength.h"
18 //#include "lengthcombo.h"
19
20 #include "support/docstring.h"
21
22 #include <vector>
23
24 class LengthCombo;
25 class QComboBox;
26 class QLineEdit;
27 class QString;
28 class QChar;
29
30 std::string makeFontName(std::string const & family, std::string const & foundry);
31
32 std::pair<std::string,std::string> parseFontName(std::string const & name);
33
34 /// method to get a LyXLength from widgets (LengthCombo)
35 std::string widgetsToLength(QLineEdit const * input, LengthCombo const * combo);
36 /// method to get a LyXLength from widgets (QComboBox)
37 LyXLength widgetsToLength(QLineEdit const * input, QComboBox const * combo);
38
39 /// method to set widgets from a LyXLength
40 void lengthToWidgets(QLineEdit * input, LengthCombo * combo,
41         std::string const & len, LyXLength::UNIT default_unit);
42
43 /// format a string to the given width
44 lyx::docstring const formatted(lyx::docstring const & text, int w = 80);
45
46 /**
47  * toqstr - convert char * into unicode
48  *
49  * Use this whenever there's a user-visible string that is encoded
50  * for the locale (menus, dialogs etc.)
51  */
52 QString const toqstr(char const * str);
53
54
55 /**
56  * toqstr - convert string into unicode
57  *
58  * Use this whenever there's a user-visible string that is encoded
59  * for the locale (menus, dialogs etc.)
60  */
61 QString const toqstr(std::string const & str);
62
63
64 /**
65  * toqstr - convert ucs4 into QString
66  *
67  * QString uses ucs2 (a.k.a utf16) internally.
68  */
69 QString const toqstr(lyx::docstring const & ucs4);
70
71 QString const ucs4_to_qstring(lyx::char_type const * str, size_t ls);
72
73 lyx::docstring const qstring_to_ucs4(QString const & qstr);
74
75 void qstring_to_ucs4(QString const & qstr, std::vector<lyx::char_type> & ucs4);
76
77 lyx::char_type const qchar_to_ucs4(QChar const & qchar);
78
79 QChar const ucs4_to_qchar(lyx::char_type const & ucs4);
80
81
82 /**
83  * qt_ - i18nize string and convert to unicode
84  *
85  * Use this in qt4/ instead of qt_()
86  */
87 QString const qt_(char const * str);
88
89
90 /**
91  * qt_ - i18nize string and convert to unicode
92  *
93  * Use this in qt4/ instead of qt_()
94  */
95 QString const qt_(std::string const & str);
96
97
98 /**
99  * fromqstr - convert QString into std::string in locale
100  *
101  * Return the QString encoded in the locale
102  */
103 std::string const fromqstr(QString const & str);
104
105 #endif // QTHELPERS_H