]> git.lyx.org Git - lyx.git/blobdiff - src/combox.h
More fixes to insettabular/text (and some missing features added).
[lyx.git] / src / combox.h
index 8dee29f1fcdf0807ae6511c445620f66c21e9c07..c948c1895f84a423681b4a31c2383e97d47b41fa 100644 (file)
@@ -30,6 +30,7 @@
 
 #include FORMS_H_LOCATION
 #include <cstdlib>
+#include "LString.h"
 
 ///
 enum combox_type {
@@ -58,31 +59,37 @@ public:
        ~Combox();
 
        /** To add this object to a form. Note that there are two heights
-        for normal (button) and expanded (browser) mode each.
+           for normal (button) and expanded (browser) mode each.
+           The optional tabfolder arguments are needed to overcome an
+           xforms bug when repositioning a combox in a tab folder.
+           tabfolder1_ is the folder holding the combox.
+           If using nested tabfolders, tabfolder2_ is the "base" folder
+           holding tabfolder1_.
        */
-       void add(int x, int y, int w, int hmin, int hmax);
+       void add(int x, int y, int w, int hmin, int hmax,
+                FL_OBJECT * tabfolder1_ = 0, FL_OBJECT * tabfolder2_ = 0);
        
        /// Add lines. Same as for fl_browser object
-       void addline(char const *);
+       void addline(string const &);
        /// Add lines. Same as for fl_browser object
-       void addto(char const *);
+       void addto(string const &);
        
        /// Returns the selected item
-       int get();
+       int get() const;
    
        /// Returns a pointer to the selected line of text
-       char const * getline();
+       string const getline() const;
    
        ///  Select an arbitrary item
        void select(int);
        ///
-        bool select_text(char const *);
+        bool select_text(string const &);
    
        ///  Clear all the list
        void clear();
 
        /// Is the combox cleared (empty)
-       bool empty() { return is_empty; }
+       bool empty() const { return is_empty; }
        
        /// Remove the objects from the form they are in. 
        void remove();
@@ -106,7 +113,7 @@ public:
        ///
        void deactivate();
        ///
-        void shortcut(char const *, int);
+        void shortcut(string const &, int);
        ///
        void Redraw();
        ///
@@ -145,6 +152,10 @@ public:
        FL_OBJECT * label;
        ///
         FL_FORM* form;
+       ///
+       FL_OBJECT * tabfolder1;
+       ///
+       FL_OBJECT * tabfolder2;
 };
 
 
@@ -152,10 +163,10 @@ public:
 //-----------------  Inline methods  --------------------------- 
 
 inline
-void Combox::addto(char const * text)
+void Combox::addto(string const & text)
 {
        if (browser) {
-               fl_addto_browser(browser, text);
+               fl_addto_browser(browser, text.c_str());
                is_empty = false;
        }
 }
@@ -178,10 +189,10 @@ void Combox::gravity(unsigned g1, unsigned g2)
 
 
 inline
-void Combox::shortcut(char const * s, int i)
+void Combox::shortcut(string const & s, int i)
 {
    if (button)
-      fl_set_object_shortcut(button, s, i);
+      fl_set_object_shortcut(button, s.c_str(), i);
 }
 
 
@@ -208,19 +219,20 @@ void Combox::setpost(FL_COMBO_PRE_POST cb)
 
 
 inline
-int Combox::get()
+int Combox::get() const
 {
    return sel;
 }
 
 
 inline
-char const * Combox::getline()
+string const Combox::getline() const
 {
     if (type == FL_COMBOX_INPUT) 
       return fl_get_input(label);
     else
-      return browser ? fl_get_browser_line(browser, sel) : 0;
+      return (browser && sel > 0) ?
+             fl_get_browser_line(browser, sel) : string();
 }
 
 #endif