]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/xforms_helpers.h
use exclicit temp var
[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 // what we always need for lengths
20 string const choice_Length_All =
21     "cm|mm|in|t%%|c%%|p%%|l%%|ex|em|pt|sp|bp|dd|pc|cc|mu";
22 string const choice_Length_WithUnit =
23     "cm|mm|in|ex|em|pt|sp|bp|dd|pc|cc|mu";      // all with a Unit
24
25 /// Extract shortcut from <ident>|<shortcut> string
26 char const * flyx_shortcut_extract(char const * sc);
27 /// Shortcut for flyx_shortcut_extract
28 #define scex flyx_shortcut_extract
29
30 /// Extract shortcut from <ident>|<shortcut> string
31 char const * flyx_ident_extract(char const * sc);
32 /// Shortcut for flyx_ident_extract
33 #define idex flyx_ident_extract
34
35 /// Set an FL_OBJECT to activated or deactivated
36 void setEnabled(FL_OBJECT *, bool enable);
37
38 /// Take a string and add breaks so that it fits into a desired label width, w
39 string formatted(string const &label, int w,
40                  int = FL_NORMAL_SIZE, int = FL_NORMAL_STYLE);
41
42 /// Given an fl_choice, create a vector of its entries
43 std::vector<string> const getVectorFromChoice(FL_OBJECT *);
44
45 /// Given an fl_browser, create a vector of its entries
46 std::vector<string> const getVectorFromBrowser(FL_OBJECT *);
47
48 /// Given an fl_input, return its contents.
49 string const getStringFromInput(FL_OBJECT * ob);
50
51 /** Given an fl_browser, return the contents of line
52     (xforms numbering convention; starts at 1).
53 */
54 string const getStringFromBrowser(FL_OBJECT * ob, int line);
55 /** Given an fl_browser, return the contents of the currently
56     highlighted line.
57 */
58 string const getSelectedStringFromBrowser(FL_OBJECT * ob);
59
60 /// Given input and choice widgets, create a string such as "1cm"
61 string getLengthFromWidgets(FL_OBJECT * input, FL_OBJECT * choice);
62
63 /** Given a string such as "1cm", set the input and choice widgets.
64     If the string is empty, the choice will be set to default_unit.
65  */
66 void updateWidgetsFromLengthString(FL_OBJECT * input, FL_OBJECT * choice,
67                                    string const & str,
68                                    string const & default_unit);
69
70 /** Given a LyXLength, set the input and choice widgets.
71     If the length is null, the choice will be set to default_unit.
72  */
73 void updateWidgetsFromLength(FL_OBJECT * input, FL_OBJECT * choice,
74                              LyXLength const & len,
75                              string const & default_unit);
76
77 /// struct holding xform-specific colors
78 struct XformsColor : public NamedColor {
79         int colorID;
80         XformsColor() : NamedColor(), colorID(0) {}
81         static bool read(string const &);
82         static bool write(string const &);
83 };
84
85
86 /** Some functions that perform some quite detailed tests to ascertain whether
87     the directory or file is readable or writeable. If not, then an error
88     message is placed in error_message. */
89 class RWInfo {
90 public:
91         ///
92         static bool WriteableDir(string const & dir);
93         ///
94         static bool ReadableDir(string const & dir);
95         ///
96         static bool WriteableFile(string const & file);
97         ///
98         static bool ReadableFile(string const & file);
99         ///
100         static string const & ErrorMessage() { return error_message; }
101 private:
102         ///
103         static string error_message;
104 };
105 #endif // XFORMSHELPERS_H