]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/xforms_helpers.h
sourcedoc-friendly files.
[lyx.git] / src / frontends / xforms / xforms_helpers.h
1 // -*- C++ -*-
2 /**
3  * \file xforms_helpers.h
4  * Copyright 2002 the LyX Team
5  * Read the file COPYING
6  *
7  * \author Angus Leeming, a.leeming@ic.ac.uk
8  */
9
10 #ifndef XFORMSHELPERS_H
11 #define XFORMSHELPERS_H
12
13 #ifdef __GNUG_
14 #pragma interface
15 #endif
16
17 #include FORMS_H_LOCATION
18  
19 #include "Color.h"
20 #include "LString.h"
21  
22 #include <vector>
23
24 class LyXLength;
25
26 // what we always need for lengths
27 string const choice_Length_All =
28     "cm|mm|in|t%%|c%%|p%%|l%%|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
31
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
36
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
41
42 /// Set an FL_OBJECT to activated or deactivated
43 void setEnabled(FL_OBJECT *, bool enable);
44
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);
48
49 /// Given an fl_choice, create a vector of its entries
50 std::vector<string> const getVectorFromChoice(FL_OBJECT *);
51
52 /// Given an fl_browser, create a vector of its entries
53 std::vector<string> const getVectorFromBrowser(FL_OBJECT *);
54
55 /// Given an fl_input, return its contents.
56 string const getStringFromInput(FL_OBJECT * ob);
57
58 /** Given an fl_browser, return the contents of line
59     (xforms numbering convention; starts at 1).
60 */
61 string const getStringFromBrowser(FL_OBJECT * ob, int line);
62 /** Given an fl_browser, return the contents of the currently
63     highlighted line.
64 */
65 string const getSelectedStringFromBrowser(FL_OBJECT * ob);
66
67 /// Given input and choice widgets, create a string such as "1cm"
68 string getLengthFromWidgets(FL_OBJECT * input, FL_OBJECT * choice);
69
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.
72  */
73 void updateWidgetsFromLengthString(FL_OBJECT * input, FL_OBJECT * choice,
74                                    string const & str,
75                                    string const & default_unit);
76
77 /** Given a LyXLength, set the input and choice widgets.
78     If the length is null, the choice will be set to default_unit.
79  */
80 void updateWidgetsFromLength(FL_OBJECT * input, FL_OBJECT * choice,
81                              LyXLength const & len,
82                              string const & default_unit);
83
84 /// struct holding xform-specific colors
85 struct XformsColor : public NamedColor {
86         int colorID;
87         XformsColor() : NamedColor(), colorID(0) {}
88         static bool read(string const &);
89         static bool write(string const &);
90 };
91
92
93 /** Some functions that perform some quite detailed tests to ascertain whether
94     the directory or file is readable or writeable. If not, then an error
95     message is placed in error_message. */
96 class RWInfo {
97 public:
98         ///
99         static bool WriteableDir(string const & dir);
100         ///
101         static bool ReadableDir(string const & dir);
102         ///
103         static bool WriteableFile(string const & file);
104         ///
105         static bool ReadableFile(string const & file);
106         ///
107         static string const & ErrorMessage() { return error_message; }
108 private:
109         ///
110         static string error_message;
111 };
112 #endif // XFORMSHELPERS_H