]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/xforms/xforms_helpers.h
remove defaults stuff, let Qt handle no toolbar
[lyx.git] / src / frontends / xforms / xforms_helpers.h
index f17fdd07585b03a98a51b9a38a1e7204bb6cbdc5..bdc4580ea1831b1b3851daf152ed0da7624a141a 100644 (file)
@@ -1,43 +1,58 @@
 // -*- C++ -*-
+/**
+ * \file xforms_helpers.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Angus Leeming
+ *
+ * Full author contact details are available in file CREDITS
+ */
 
 #ifndef XFORMSHELPERS_H
 #define XFORMSHELPERS_H
 
-#ifdef __GNUG_
-#pragma interface
-#endif
 
-#include <config.h>
-#include FORMS_H_LOCATION
+#include "forms_fwd.h"
+
 #include "Color.h"
-#include "support/lstrings.h"
+#include "LString.h"
+
+#include <algorithm>
 #include <vector>
 
-/// Extract shortcut from <ident>|<shortcut> string
-char const * flyx_shortcut_extract(char const * sc);
-/// Shortcut for flyx_shortcut_extract
-#define scex flyx_shortcut_extract
+class LyXLength;
+
+/// parse "&Save" etc. to <"Save", "#S">. Does not handle &&
+std::pair<string, string> parse_shortcut(string const & str);
 
-/// Extract shortcut from <ident>|<shortcut> string
-char const * flyx_ident_extract(char const * sc);
-/// Shortcut for flyx_ident_extract
-#define idex flyx_ident_extract
+// A wrapper for the xforms routine, but this one accepts uint args
+unsigned long fl_getmcolor(int i, unsigned int * r, unsigned int * g,
+                          unsigned int * b);
+
+// what we always need for lengths
+string const choice_Length_All =
+    "cm|mm|in|text%%|col%%|page%%|line%%|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
+
+/// return the (in)active state of the object
+bool isActive(FL_OBJECT * ob);
 
 /// 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=FL_NORMAL_SIZE, int=FL_NORMAL_STYLE);
+                int = 12 /*FL_NORMAL_SIZE*/, int = 0 /*FL_NORMAL_STYLE*/);
 
-/// Given an fl_choice, create a vector of its entries
-std::vector<string> const getVectorFromChoice(FL_OBJECT *);
+/// Given an fl_choice or an fl_browser, create a vector of its entries
+std::vector<string> const getVector(FL_OBJECT *);
 
-/// Given an fl_browser, create a vector of its entries
-std::vector<string> const getVectorFromBrowser(FL_OBJECT *);
+/** Given an fl_input, an fl_choice or an fl_browser, return an entry
+    \c num is the position for the string, where 0 means "current item"
+ */
+string const getString(FL_OBJECT * ob, int num = 0);
 
 /// Given input and choice widgets, create a string such as "1cm"
 string getLengthFromWidgets(FL_OBJECT * input, FL_OBJECT * choice);
@@ -49,6 +64,32 @@ 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);
+
+
+/** Return the position of val in the vector if found.
+    If not found, return 0.
+ */
+template<class A>
+typename std::vector<A>::size_type
+findPos(std::vector<A> const & vec, A const & val)
+{
+       typename std::vector<A>::const_iterator it =
+               std::find(vec.begin(), vec.end(), val);
+       if (it == vec.end())
+               return 0;
+       return std::distance(vec.begin(), it);
+}
+
+/// Called from Preferences when the cursor color is changed.
+void setCursorColor(int color);
+
+
 /// struct holding xform-specific colors
 struct XformsColor : public NamedColor {
        int colorID;