]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/qt_helpers.h
rename/merge LyXLength related stuff
[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  * \author Richard Heck
9  *
10  * Full author contact details are available in file CREDITS.
11  */
12
13 #ifndef QTHELPERS_H
14 #define QTHELPERS_H
15
16 #include "Length.h"
17 #include "support/docstring.h"
18 #include "support/qstring_helpers.h"
19
20 #include <QString>
21 #include <utility>
22
23 class QComboBox;
24 class QLineEdit;
25 class QCheckBox;
26
27 class LengthCombo;
28
29 namespace lyx {
30
31 std::string makeFontName(std::string const & family, std::string const & foundry);
32
33 std::pair<std::string,std::string> parseFontName(std::string const & name);
34
35 /// method to get a Length from widgets (LengthCombo)
36 std::string widgetsToLength(QLineEdit const * input, LengthCombo const * combo);
37 /// method to get a Length from widgets (QComboBox)
38 Length widgetsToLength(QLineEdit const * input, QComboBox const * combo);
39
40 //FIXME It would be nice if defaultUnit were a default argument
41 /// method to set widgets from a Length
42 void lengthToWidgets(QLineEdit * input, LengthCombo * combo, 
43         Length const & len, Length::UNIT default_unit);
44 /// method to set widgets from a string
45 void lengthToWidgets(QLineEdit * input, LengthCombo * combo,
46         std::string const & len, Length::UNIT default_unit);
47 /// method to set widgets from a Length with optional "auto" if zero
48 void lengthAutoToWidgets(QLineEdit * input, LengthCombo * combo, 
49         Length const & len, Length::UNIT defaultUnit);
50
51 //FIXME setAutoTextCB should really take an argument, as indicated, that
52 //determines what text is to be written for "auto". But making
53 //that work involves more extensive revisions than we now want
54 //to make, since "auto" also appears in update_contents() (see
55 //QGraphics.cpp). 
56 //The right way to do this, I think, would be to define a class
57 //checkedLengthSet (and a partnering labeledLengthSete) that encapsulated 
58 //the checkbox, line edit, and length combo together, and then made e.g.
59 //lengthToWidgets, widgetsToLength, etc, all public methods of that class.
60 //Perhaps even the validator could be exposed through it.
61 /**
62  * sets a checkbox-line edit-length combo group, using "text" if the
63  * checkbox is unchecked and clearing the line edit if it previously
64  * said "text".
65 */
66 void setAutoTextCB(QCheckBox * checkBox, QLineEdit * lineEdit, 
67         LengthCombo * lengthCombo/*, string text = "auto"*/);
68
69
70 /// format a string to the given width
71 docstring const formatted(docstring const & text, int w = 80);
72
73
74 /**
75  * qt_ - i18nize string and convert to QString
76  *
77  * Use this in qt4/ instead of _()
78  */
79 QString const qt_(char const * str, const char * comment = 0);
80
81
82 /**
83  * qt_ - i18nize string and convert to QString
84  *
85  * Use this in qt4/ instead of _()
86  */
87 QString const qt_(std::string const & str);
88
89 } // namespace lyx
90
91 #endif // QTHELPERS_H