]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/xforms_helpers.h
Address most (if not all?) of the problems raised by Garst about the
[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 "Color.h"
11
12 /// Set an FL_OBJECT to activated or deactivated
13 void setEnabled(FL_OBJECT *, bool enable);
14
15 /// Take a string and add breaks so that it fits into a desired label width, w
16 string formatted(string const &label, int w,
17                  int=FL_NORMAL_SIZE, int=FL_NORMAL_STYLE);
18
19 /// Given an fl_choice, create a vector of its entries
20 std::vector<string> const getVectorFromChoice(FL_OBJECT *);
21
22 /// Given an fl_browser, create a vector of its entries
23 std::vector<string> const getVectorFromBrowser(FL_OBJECT *);
24
25 /// Given input and choice widgets, create a string such as "1cm"
26 string getLengthFromWidgets(FL_OBJECT * input, FL_OBJECT * choice);
27
28 /** Given a string such as "1cm", set the input and choice widgets.
29     If the string is empty, the choice will be set to default_unit.
30  */
31 void updateWidgetsFromLengthString(FL_OBJECT * input, FL_OBJECT * choice,
32                                    string const & str,
33                                    string const & default_unit);
34
35 /// struct holding xform-specific colors
36 struct XformsColor : public NamedColor {
37         int colorID;
38         XformsColor() : NamedColor(), colorID(0) {}
39         static bool read(string const &);
40         static bool write(string const &);
41 };
42
43
44 /** Some functions that perform some quite detailed tests to ascertain whether
45     the directory or file is readable or writeable. If not, then an error
46     message is placed in error_message. */
47 class RWInfo {
48 public:
49         ///
50         static bool WriteableDir(string const & dir);
51         ///
52         static bool ReadableDir(string const & dir);
53         ///
54         static bool WriteableFile(string const & file);
55         ///
56         static bool ReadableFile(string const & file);
57         ///
58         static string const & ErrorMessage() { return error_message; }
59 private:
60         ///
61         static string error_message;
62 };
63 #endif // XFORMSHELPERS_H