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