2001-06-13 14:33:31 +00:00
|
|
|
// -*- C++ -*-
|
|
|
|
|
2001-03-05 19:02:40 +00:00
|
|
|
#ifndef XFORMSHELPERS_H
|
|
|
|
#define XFORMSHELPERS_H
|
2000-11-02 14:47:47 +00:00
|
|
|
|
|
|
|
#ifdef __GNUG_
|
|
|
|
#pragma interface
|
|
|
|
#endif
|
|
|
|
|
2001-11-26 10:19:58 +00:00
|
|
|
#include FORMS_H_LOCATION
|
|
|
|
|
2000-11-15 18:02:45 +00:00
|
|
|
#include "Color.h"
|
2001-12-12 09:56:03 +00:00
|
|
|
#include "LString.h"
|
2001-11-26 10:19:58 +00:00
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
|
2001-12-12 09:56:03 +00:00
|
|
|
class LyXLength;
|
|
|
|
|
2001-11-26 10:19:58 +00:00
|
|
|
/// Extract shortcut from <ident>|<shortcut> string
|
|
|
|
char const * flyx_shortcut_extract(char const * sc);
|
|
|
|
/// Shortcut for flyx_shortcut_extract
|
|
|
|
#define scex flyx_shortcut_extract
|
|
|
|
|
|
|
|
/// Extract shortcut from <ident>|<shortcut> string
|
|
|
|
char const * flyx_ident_extract(char const * sc);
|
|
|
|
/// Shortcut for flyx_ident_extract
|
|
|
|
#define idex flyx_ident_extract
|
2000-11-02 14:47:47 +00:00
|
|
|
|
2001-09-24 16:37:24 +00:00
|
|
|
/// Set an FL_OBJECT to activated or deactivated
|
2001-03-05 19:02:40 +00:00
|
|
|
void setEnabled(FL_OBJECT *, bool enable);
|
|
|
|
|
2001-09-24 16:37:24 +00:00
|
|
|
/// Take a string and add breaks so that it fits into a desired label width, w
|
2001-03-15 13:37:04 +00:00
|
|
|
string formatted(string const &label, int w,
|
2001-12-12 09:56:03 +00:00
|
|
|
int = FL_NORMAL_SIZE, int = FL_NORMAL_STYLE);
|
2000-11-02 14:47:47 +00:00
|
|
|
|
2001-09-24 16:37:24 +00:00
|
|
|
/// Given an fl_choice, create a vector of its entries
|
|
|
|
std::vector<string> const getVectorFromChoice(FL_OBJECT *);
|
|
|
|
|
|
|
|
/// Given an fl_browser, create a vector of its entries
|
|
|
|
std::vector<string> const getVectorFromBrowser(FL_OBJECT *);
|
|
|
|
|
2002-01-15 15:31:19 +00:00
|
|
|
/// Given an fl_input, return its contents.
|
|
|
|
string const getStringFromInput(FL_OBJECT * ob);
|
|
|
|
|
|
|
|
/** Given an fl_browser, return the contents of the currently
|
|
|
|
highlighted line.
|
|
|
|
*/
|
2002-01-14 12:47:17 +00:00
|
|
|
/** Given an fl_browser, return the contents of line
|
|
|
|
(xforms numbering convention; starts at 1).
|
2002-01-08 10:05:53 +00:00
|
|
|
*/
|
|
|
|
string const getStringFromBrowser(FL_OBJECT * ob, int line);
|
2002-01-14 12:47:17 +00:00
|
|
|
/** Given an fl_browser, return the contents of the currently
|
|
|
|
highlighted line.
|
|
|
|
*/
|
|
|
|
string const getSelectedStringFromBrowser(FL_OBJECT * ob);
|
2002-01-08 10:05:53 +00:00
|
|
|
|
2001-10-09 12:36:36 +00:00
|
|
|
/// Given input and choice widgets, create a string such as "1cm"
|
|
|
|
string getLengthFromWidgets(FL_OBJECT * input, FL_OBJECT * choice);
|
|
|
|
|
2001-10-15 10:28:31 +00:00
|
|
|
/** Given a string such as "1cm", set the input and choice widgets.
|
|
|
|
If the string is empty, the choice will be set to default_unit.
|
|
|
|
*/
|
2001-10-09 12:36:36 +00:00
|
|
|
void updateWidgetsFromLengthString(FL_OBJECT * input, FL_OBJECT * choice,
|
2001-10-15 10:28:31 +00:00
|
|
|
string const & str,
|
|
|
|
string const & default_unit);
|
2001-10-09 12:36:36 +00:00
|
|
|
|
2001-12-11 17:26:52 +00:00
|
|
|
/** Given a LyXLength, set the input and choice widgets.
|
|
|
|
If the length is null, the choice will be set to default_unit.
|
|
|
|
*/
|
|
|
|
void updateWidgetsFromLength(FL_OBJECT * input, FL_OBJECT * choice,
|
|
|
|
LyXLength const & len,
|
|
|
|
string const & default_unit);
|
|
|
|
|
2000-11-15 18:02:45 +00:00
|
|
|
/// struct holding xform-specific colors
|
2001-03-05 19:02:40 +00:00
|
|
|
struct XformsColor : public NamedColor {
|
2000-11-15 18:02:45 +00:00
|
|
|
int colorID;
|
2001-03-05 19:02:40 +00:00
|
|
|
XformsColor() : NamedColor(), colorID(0) {}
|
2000-11-15 18:02:45 +00:00
|
|
|
static bool read(string const &);
|
|
|
|
static bool write(string const &);
|
|
|
|
};
|
|
|
|
|
2000-11-21 15:46:13 +00:00
|
|
|
|
|
|
|
/** Some functions that perform some quite detailed tests to ascertain whether
|
|
|
|
the directory or file is readable or writeable. If not, then an error
|
|
|
|
message is placed in error_message. */
|
|
|
|
class RWInfo {
|
|
|
|
public:
|
|
|
|
///
|
|
|
|
static bool WriteableDir(string const & dir);
|
|
|
|
///
|
|
|
|
static bool ReadableDir(string const & dir);
|
|
|
|
///
|
|
|
|
static bool WriteableFile(string const & file);
|
|
|
|
///
|
|
|
|
static bool ReadableFile(string const & file);
|
|
|
|
///
|
|
|
|
static string const & ErrorMessage() { return error_message; }
|
|
|
|
private:
|
|
|
|
///
|
|
|
|
static string error_message;
|
|
|
|
};
|
2001-03-05 19:02:40 +00:00
|
|
|
#endif // XFORMSHELPERS_H
|