X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Ffrontends%2Fxforms%2Fxforms_helpers.h;h=c4325d88012c236db156e51d5d180609d1f1a749;hb=27652900a60fd078f161ce866ddaed21dba21eff;hp=0781cd1c9ef4f37519e82a7a3d66a70d32ce02bd;hpb=765db1102d7edf01d2fd7b667c75095f843ab476;p=lyx.git diff --git a/src/frontends/xforms/xforms_helpers.h b/src/frontends/xforms/xforms_helpers.h index 0781cd1c9e..c4325d8801 100644 --- a/src/frontends/xforms/xforms_helpers.h +++ b/src/frontends/xforms/xforms_helpers.h @@ -1,3 +1,5 @@ +// -*- C++ -*- + #ifndef XFORMSHELPERS_H #define XFORMSHELPERS_H @@ -5,30 +7,75 @@ #pragma interface #endif -#include // pair -//#include -#include "LString.h" +#include FORMS_H_LOCATION + #include "Color.h" +#include "LString.h" + +#include + +class LyXLength; + +// what we always need for lengths +string const choice_Length_All = + "cm|mm|in|%%|c%%|p%%|l%%|ex|em|pt|sp|bp|dd|pc|cc|mu"; +string const choice_Length_WithUnit = + "cm|mm|in|ex|em|pt|sp|bp|dd|pc|cc|mu"; // all with a Unit + +/// Extract shortcut from | string +char const * flyx_shortcut_extract(char const * sc); +/// Shortcut for flyx_shortcut_extract +#define scex flyx_shortcut_extract + +/// Extract shortcut from | string +char const * flyx_ident_extract(char const * sc); +/// Shortcut for flyx_ident_extract +#define idex flyx_ident_extract -// Set an FL_OBJECT to activated or deactivated +/// Set an FL_OBJECT to activated or deactivated void setEnabled(FL_OBJECT *, bool enable); -// Take a string and add breaks so that it fits into a desired label width, w -string formatted(string const &label, int w, int size, int style); +/// Take a string and add breaks so that it fits into a desired label width, w +string formatted(string const &label, int w, + int = FL_NORMAL_SIZE, int = FL_NORMAL_STYLE); -class LyXView; - -/** Launch a file dialog and return the chosen file. - filename: a suggested filename. - title: the title of the dialog. - pattern: *.ps etc. - dir1 = (name, dir), dir2 = (name, dir): extra buttons on the dialog. +/// Given an fl_choice, create a vector of its entries +std::vector const getVectorFromChoice(FL_OBJECT *); + +/// Given an fl_browser, create a vector of its entries +std::vector const getVectorFromBrowser(FL_OBJECT *); + +/// 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. +*/ +/** Given an fl_browser, return the contents of line + (xforms numbering convention; starts at 1). */ -string const browseFile(LyXView *lv, string const & filename, - string const & title, - string const & pattern, - std::pair const & dir1, - std::pair const & dir2); +string const getStringFromBrowser(FL_OBJECT * ob, int line); +/** Given an fl_browser, return the contents of the currently + highlighted line. +*/ +string const getSelectedStringFromBrowser(FL_OBJECT * ob); + +/// Given input and choice widgets, create a string such as "1cm" +string getLengthFromWidgets(FL_OBJECT * input, FL_OBJECT * choice); + +/** 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. + */ +void updateWidgetsFromLengthString(FL_OBJECT * input, FL_OBJECT * choice, + string const & str, + string const & default_unit); + +/** 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); /// struct holding xform-specific colors struct XformsColor : public NamedColor {