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
44 /// callback prototype
45 typedef void (*FL_COMBO_CB) (int, void *);
46 /// pre post prototype
47 typedef void (*FL_COMBO_PRE_POST) ();
54 explicit Combox(combox_type t = FL_COMBOX_NORMAL);
58 /** To add this object to a form. Note that there are two heights
59 for normal (button) and expanded (browser) mode each.
61 void add(int x, int y, int w, int hmin, int hmax);
63 /// Add lines. Same as for fl_browser object
64 void addline(char const *);
65 /// Add lines. Same as for fl_browser object
66 void addto(char const *);
68 /// Returns the selected item
71 /// Returns a pointer to the selected line of text
72 char const * getline();
74 /// Select an arbitrary item
77 bool select_text(char const *);
79 /// Clear all the list
82 /// Is the combox cleared (empty)
83 bool empty() { return is_empty; }
85 /// Remove the objects from the form they are in.
88 /** Assign a callback to this object. The callback should be a void
89 function with a int and a void pointer as parameters.
91 void setcallback(FL_COMBO_CB, void *);
94 void setpre(FL_COMBO_PRE_POST);
96 void setpost(FL_COMBO_PRE_POST);
99 void resize(unsigned);
101 void gravity(unsigned, unsigned);
107 void shortcut(char const *, int);
113 static void combo_cb(FL_OBJECT *, long);
115 static void input_cb(FL_OBJECT *, long);
117 static int peek_event(FL_FORM *, void *);
119 /// At least Hide should not be public
120 void Hide(int who = 0);
133 FL_COMBO_CB callback;
137 FL_COMBO_PRE_POST _pre;
139 FL_COMBO_PRE_POST _post;
150 //----------------- Inline methods ---------------------------
153 void Combox::addto(char const * text)
156 fl_addto_browser(browser, text);
163 void Combox::resize(unsigned r)
165 fl_set_object_resize(button, r);
166 if (label!= button) fl_set_object_resize(label, r);
171 void Combox::gravity(unsigned g1, unsigned g2)
173 fl_set_object_gravity(button, g1, g2);
174 if (label!= button) fl_set_object_gravity(label, g1, g2);
179 void Combox::shortcut(char const * s, int i)
182 fl_set_object_shortcut(button, s, i);
187 void Combox::setcallback(FL_COMBO_CB cb, void * a = 0)
195 void Combox::setpre(FL_COMBO_PRE_POST cb)
202 void Combox::setpost(FL_COMBO_PRE_POST cb)
216 char const * Combox::getline()
218 if (type == FL_COMBOX_INPUT)
219 return fl_get_input(label);
221 return browser ? fl_get_browser_line(browser, sel) : 0;