]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/xforms_helpers.h
John's spellchecker patch plus a new helper function getStringFromBrowser.
[lyx.git] / src / frontends / xforms / xforms_helpers.h
1 // -*- C++ -*-
2
3 #ifndef XFORMSHELPERS_H
4 #define XFORMSHELPERS_H
5
6 #ifdef __GNUG_
7 #pragma interface
8 #endif
9
10 #include FORMS_H_LOCATION
11  
12 #include "Color.h"
13 #include "LString.h"
14  
15 #include <vector>
16
17 class LyXLength;
18
19 /// Extract shortcut from <ident>|<shortcut> string
20 char const * flyx_shortcut_extract(char const * sc);
21 /// Shortcut for flyx_shortcut_extract
22 #define scex flyx_shortcut_extract
23
24 /// Extract shortcut from <ident>|<shortcut> string
25 char const * flyx_ident_extract(char const * sc);
26 /// Shortcut for flyx_ident_extract
27 #define idex flyx_ident_extract
28
29 /// Set an FL_OBJECT to activated or deactivated
30 void setEnabled(FL_OBJECT *, bool enable);
31
32 /// Take a string and add breaks so that it fits into a desired label width, w
33 string formatted(string const &label, int w,
34                  int = FL_NORMAL_SIZE, int = FL_NORMAL_STYLE);
35
36 /// Given an fl_choice, create a vector of its entries
37 std::vector<string> const getVectorFromChoice(FL_OBJECT *);
38
39 /// Given an fl_browser, create a vector of its entries
40 std::vector<string> const getVectorFromBrowser(FL_OBJECT *);
41
42 /** Given an fl_browser, return the contents of the currently
43     highlighted line (xforms numbering convention; starts at 1).
44     If nothing is selected, return an empty string.
45     This function, although apparently overkill, ensures that we don't get
46     unexpected crashes.
47 */
48 string const getStringFromBrowser(FL_OBJECT * ob, int line);
49
50 /// Given input and choice widgets, create a string such as "1cm"
51 string getLengthFromWidgets(FL_OBJECT * input, FL_OBJECT * choice);
52
53 /** Given a string such as "1cm", set the input and choice widgets.
54     If the string is empty, the choice will be set to default_unit.
55  */
56 void updateWidgetsFromLengthString(FL_OBJECT * input, FL_OBJECT * choice,
57                                    string const & str,
58                                    string const & default_unit);
59
60 /** Given a LyXLength, set the input and choice widgets.
61     If the length is null, the choice will be set to default_unit.
62  */
63 void updateWidgetsFromLength(FL_OBJECT * input, FL_OBJECT * choice,
64                              LyXLength const & len,
65                              string const & default_unit);
66
67 /// struct holding xform-specific colors
68 struct XformsColor : public NamedColor {
69         int colorID;
70         XformsColor() : NamedColor(), colorID(0) {}
71         static bool read(string const &);
72         static bool write(string const &);
73 };
74
75
76 /** Some functions that perform some quite detailed tests to ascertain whether
77     the directory or file is readable or writeable. If not, then an error
78     message is placed in error_message. */
79 class RWInfo {
80 public:
81         ///
82         static bool WriteableDir(string const & dir);
83         ///
84         static bool ReadableDir(string const & dir);
85         ///
86         static bool WriteableFile(string const & file);
87         ///
88         static bool ReadableFile(string const & file);
89         ///
90         static string const & ErrorMessage() { return error_message; }
91 private:
92         ///
93         static string error_message;
94 };
95 #endif // XFORMSHELPERS_H