3 * Combox: A combination of two objects (a button and a browser) is
4 * encapsulated to get a combobox-like object. All XForms
5 * functions are hidden.
7 * GNU Copyleft 1996 Alejandro Aguilar Sierra <asierra@servidor.unam.mx>
10 * Dependencies: Only XForms, but created to be used with LyX.
16 * 2/06/1996, Alejandro Aguilar Sierra
19 * 4/06/1996, Alejandro Aguilar Sierra
20 * Added droplist mode (a button with a black down arrow at right)
21 * and support for middle and right buttons, as XForms choice object.
31 #include FORMS_H_LOCATION
46 /// callback prototype
47 typedef void (*FL_COMBO_CB) (int, void *, Combox *);
48 /// pre post prototype
49 typedef void (*FL_COMBO_PRE_POST) ();
56 explicit Combox(combox_type t = FL_COMBOX_NORMAL);
60 /** To add this object to a form. Note that there are two heights
61 for normal (button) and expanded (browser) mode each.
63 void add(int x, int y, int w, int hmin, int hmax);
65 /// Add lines. Same as for fl_browser object
66 void addline(char const *);
67 /// Add lines. Same as for fl_browser object
68 void addto(char const *);
70 /// Returns the selected item
73 /// Returns a pointer to the selected line of text
74 char const * getline();
76 /// Select an arbitrary item
79 bool select_text(char const *);
81 /// Clear all the list
84 /// Is the combox cleared (empty)
85 bool empty() { return is_empty; }
87 /// Remove the objects from the form they are in.
90 /** Assign a callback to this object. The callback should be a void
91 function with a int and a void pointer as parameters.
93 void setcallback(FL_COMBO_CB, void *);
96 void setpre(FL_COMBO_PRE_POST);
98 void setpost(FL_COMBO_PRE_POST);
100 /// XForms attributes
101 void resize(unsigned);
103 void gravity(unsigned, unsigned);
109 void shortcut(char const *, int);
115 static void combo_cb(FL_OBJECT *, long);
117 static void input_cb(FL_OBJECT *, long);
119 static int peek_event(FL_FORM *, void *);
121 /// At least Hide should not be public
122 void Hide(int who = 0);
135 FL_COMBO_CB callback;
139 FL_COMBO_PRE_POST _pre;
141 FL_COMBO_PRE_POST _post;
152 //----------------- Inline methods ---------------------------
155 void Combox::addto(char const * text)
158 fl_addto_browser(browser, text);
165 void Combox::resize(unsigned r)
167 fl_set_object_resize(button, r);
168 if (label!= button) fl_set_object_resize(label, r);
173 void Combox::gravity(unsigned g1, unsigned g2)
175 fl_set_object_gravity(button, g1, g2);
176 if (label!= button) fl_set_object_gravity(label, g1, g2);
181 void Combox::shortcut(char const * s, int i)
184 fl_set_object_shortcut(button, s, i);
189 void Combox::setcallback(FL_COMBO_CB cb, void * a = 0)
197 void Combox::setpre(FL_COMBO_PRE_POST cb)
204 void Combox::setpost(FL_COMBO_PRE_POST cb)
218 char const * Combox::getline()
220 if (type == FL_COMBOX_INPUT)
221 return fl_get_input(label);
223 return browser ? fl_get_browser_line(browser, sel) : 0;