3 #ifndef XFORMSHELPERS_H
4 #define XFORMSHELPERS_H
10 #include FORMS_H_LOCATION
19 // what we always need for lengths
20 string const choice_Length_All =
21 "cm|mm|in|%%|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
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
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
35 /// Set an FL_OBJECT to activated or deactivated
36 void setEnabled(FL_OBJECT *, bool enable);
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);
42 /// Given an fl_choice, create a vector of its entries
43 std::vector<string> const getVectorFromChoice(FL_OBJECT *);
45 /// Given an fl_browser, create a vector of its entries
46 std::vector<string> const getVectorFromBrowser(FL_OBJECT *);
48 /// Given an fl_input, return its contents.
49 string const getStringFromInput(FL_OBJECT * ob);
51 /** Given an fl_browser, return the contents of the currently
54 /** Given an fl_browser, return the contents of line
55 (xforms numbering convention; starts at 1).
57 string const getStringFromBrowser(FL_OBJECT * ob, int line);
58 /** Given an fl_browser, return the contents of the currently
61 string const getSelectedStringFromBrowser(FL_OBJECT * ob);
63 /// Given input and choice widgets, create a string such as "1cm"
64 string getLengthFromWidgets(FL_OBJECT * input, FL_OBJECT * choice);
66 /** Given a string such as "1cm", set the input and choice widgets.
67 If the string is empty, the choice will be set to default_unit.
69 void updateWidgetsFromLengthString(FL_OBJECT * input, FL_OBJECT * choice,
71 string const & default_unit);
73 /** Given a LyXLength, set the input and choice widgets.
74 If the length is null, the choice will be set to default_unit.
76 void updateWidgetsFromLength(FL_OBJECT * input, FL_OBJECT * choice,
77 LyXLength const & len,
78 string const & default_unit);
80 /// struct holding xform-specific colors
81 struct XformsColor : public NamedColor {
83 XformsColor() : NamedColor(), colorID(0) {}
84 static bool read(string const &);
85 static bool write(string const &);
89 /** Some functions that perform some quite detailed tests to ascertain whether
90 the directory or file is readable or writeable. If not, then an error
91 message is placed in error_message. */
95 static bool WriteableDir(string const & dir);
97 static bool ReadableDir(string const & dir);
99 static bool WriteableFile(string const & file);
101 static bool ReadableFile(string const & file);
103 static string const & ErrorMessage() { return error_message; }
106 static string error_message;
108 #endif // XFORMSHELPERS_H