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 (C) 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 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. */
60 void add(int x
, int y
, int w
, int hmin
, int hmax
);
62 /// Add lines. Same as for fl_browser object
63 void addline(char const*);
64 /// Add lines. Same as for fl_browser object
65 void addto(char const*);
67 /// Returns the selected item
70 /// Returns a pointer to the selected line of text
73 /// Select an arbitrary item
76 bool select_text(char const*);
78 /// Clear all the list
81 /// Is the combox cleared (empty)
82 bool empty() { return is_empty
; }
84 /// Remove the objects from the form they are in.
87 /** Assign a callback to this object. The callback should be a void
88 function with a int and a void pointer as parameters. */
89 void setcallback(FL_COMBO_CB
, void *);
92 void setpre(FL_COMBO_PRE_POST
);
94 void setpost(FL_COMBO_PRE_POST
);
97 void resize(unsigned);
99 void gravity(unsigned, unsigned);
105 void shortcut(char const*, int);
111 static void combo_cb(FL_OBJECT
*, long);
113 static void input_cb(FL_OBJECT
*, long);
115 static int peek_event(FL_FORM
*, void *);
117 /// At least Hide should not be public
118 void Hide(int who
= 0);
131 FL_COMBO_CB callback
;
135 FL_COMBO_PRE_POST _pre
;
137 FL_COMBO_PRE_POST _post
;
148 //----------------- Inline methods ---------------------------
151 void Combox::addto(char const* text
)
154 fl_addto_browser(browser
, text
);
160 void Combox::resize(unsigned r
)
162 fl_set_object_resize(button
, r
);
163 if (label
!=button
) fl_set_object_resize(label
, r
);
167 void Combox::gravity(unsigned g1
, unsigned g2
)
169 fl_set_object_gravity(button
, g1
, g2
);
170 if (label
!=button
) fl_set_object_gravity(label
, g1
, g2
);
174 void Combox::shortcut(char const* s
, int i
)
177 fl_set_object_shortcut(button
,s
,i
);
181 void Combox::setcallback(FL_COMBO_CB cb
, void *a
= 0)
188 void Combox::setpre(FL_COMBO_PRE_POST cb
)
194 void Combox::setpost(FL_COMBO_PRE_POST cb
)
206 char const*Combox::getline()
208 if (type
==FL_COMBOX_INPUT
)
209 return fl_get_input(label
);
211 return ((browser
) ? fl_get_browser_line(browser
, sel
): (char const*)0);