3 * \file xforms_helpers.h
4 * Copyright 2002 the LyX Team
5 * Read the file COPYING
7 * \author Angus Leeming, a.leeming@ic.ac.uk
10 #ifndef XFORMSHELPERS_H
11 #define XFORMSHELPERS_H
17 #include FORMS_H_LOCATION
26 // what we always need for lengths
27 string const choice_Length_All =
28 "cm|mm|in|text%%|col%%|page%%|line%%|ex|em|pt|sp|bp|dd|pc|cc|mu";
29 string const choice_Length_WithUnit =
30 "cm|mm|in|ex|em|pt|sp|bp|dd|pc|cc|mu"; // all with a Unit
32 /// Extract shortcut from <ident>|<shortcut> string
33 char const * flyx_shortcut_extract(char const * sc);
34 /// Shortcut for flyx_shortcut_extract
35 #define scex flyx_shortcut_extract
37 /// Extract shortcut from <ident>|<shortcut> string
38 char const * flyx_ident_extract(char const * sc);
39 /// Shortcut for flyx_ident_extract
40 #define idex flyx_ident_extract
42 /// Set an FL_OBJECT to activated or deactivated
43 void setEnabled(FL_OBJECT *, bool enable);
45 /// Take a string and add breaks so that it fits into a desired label width, w
46 string formatted(string const &label, int w,
47 int = FL_NORMAL_SIZE, int = FL_NORMAL_STYLE);
49 /// Given an fl_choice, create a vector of its entries
50 std::vector<string> const getVectorFromChoice(FL_OBJECT *);
52 /// Given an fl_browser, create a vector of its entries
53 std::vector<string> const getVectorFromBrowser(FL_OBJECT *);
55 /// Given an fl_input, return its contents.
56 string const getStringFromInput(FL_OBJECT * ob);
58 /** Given an fl_browser, return the contents of line
59 (xforms numbering convention; starts at 1).
61 string const getStringFromBrowser(FL_OBJECT * ob, int line);
62 /** Given an fl_browser, return the contents of the currently
65 string const getSelectedStringFromBrowser(FL_OBJECT * ob);
67 /// Given input and choice widgets, create a string such as "1cm"
68 string getLengthFromWidgets(FL_OBJECT * input, FL_OBJECT * choice);
70 /** Given a string such as "1cm", set the input and choice widgets.
71 If the string is empty, the choice will be set to default_unit.
73 void updateWidgetsFromLengthString(FL_OBJECT * input, FL_OBJECT * choice,
75 string const & default_unit);
77 /** Given a LyXLength, set the input and choice widgets.
78 If the length is null, the choice will be set to default_unit.
80 void updateWidgetsFromLength(FL_OBJECT * input, FL_OBJECT * choice,
81 LyXLength const & len,
82 string const & default_unit);
85 /// Called from Preferences when the cursor color is changed.
86 void setCursorColor(int color);
89 /// struct holding xform-specific colors
90 struct XformsColor : public NamedColor {
92 XformsColor() : NamedColor(), colorID(0) {}
93 static bool read(string const &);
94 static bool write(string const &);
98 /** Some functions that perform some quite detailed tests to ascertain whether
99 the directory or file is readable or writeable. If not, then an error
100 message is placed in error_message. */
104 static bool WriteableDir(string const & dir);
106 static bool ReadableDir(string const & dir);
108 static bool WriteableFile(string const & file);
110 static bool ReadableFile(string const & file);
112 static string const & ErrorMessage() { return error_message; }
115 static string error_message;
117 #endif // XFORMSHELPERS_H