]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/xforms_helpers.h
use LyXLength for tabular pwidth
[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 <config.h>
11  
12 #include FORMS_H_LOCATION
13  
14 #include "Color.h"
15 #include "support/lstrings.h"
16 #include "lyxlength.h"
17  
18 #include <vector>
19
20 /// Extract shortcut from <ident>|<shortcut> string
21 char const * flyx_shortcut_extract(char const * sc);
22 /// Shortcut for flyx_shortcut_extract
23 #define scex flyx_shortcut_extract
24
25 /// Extract shortcut from <ident>|<shortcut> string
26 char const * flyx_ident_extract(char const * sc);
27 /// Shortcut for flyx_ident_extract
28 #define idex flyx_ident_extract
29
30 /// Set an FL_OBJECT to activated or deactivated
31 void setEnabled(FL_OBJECT *, bool enable);
32
33 /// Take a string and add breaks so that it fits into a desired label width, w
34 string formatted(string const &label, int w,
35                  int=FL_NORMAL_SIZE, int=FL_NORMAL_STYLE);
36
37 /// Given an fl_choice, create a vector of its entries
38 std::vector<string> const getVectorFromChoice(FL_OBJECT *);
39
40 /// Given an fl_browser, create a vector of its entries
41 std::vector<string> const getVectorFromBrowser(FL_OBJECT *);
42
43 /// Given input and choice widgets, create a string such as "1cm"
44 string getLengthFromWidgets(FL_OBJECT * input, FL_OBJECT * choice);
45
46 /** Given a string such as "1cm", set the input and choice widgets.
47     If the string is empty, the choice will be set to default_unit.
48  */
49 void updateWidgetsFromLengthString(FL_OBJECT * input, FL_OBJECT * choice,
50                                    string const & str,
51                                    string const & default_unit);
52
53 /** Given a LyXLength, set the input and choice widgets.
54     If the length is null, the choice will be set to default_unit.
55  */
56 void updateWidgetsFromLength(FL_OBJECT * input, FL_OBJECT * choice,
57                              LyXLength const & len,
58                              string const & default_unit);
59
60 /// struct holding xform-specific colors
61 struct XformsColor : public NamedColor {
62         int colorID;
63         XformsColor() : NamedColor(), colorID(0) {}
64         static bool read(string const &);
65         static bool write(string const &);
66 };
67
68
69 /** Some functions that perform some quite detailed tests to ascertain whether
70     the directory or file is readable or writeable. If not, then an error
71     message is placed in error_message. */
72 class RWInfo {
73 public:
74         ///
75         static bool WriteableDir(string const & dir);
76         ///
77         static bool ReadableDir(string const & dir);
78         ///
79         static bool WriteableFile(string const & file);
80         ///
81         static bool ReadableFile(string const & file);
82         ///
83         static string const & ErrorMessage() { return error_message; }
84 private:
85         ///
86         static string error_message;
87 };
88 #endif // XFORMSHELPERS_H