+2003-04-03 Angus Leeming <leeming@lyx.org>
+
+ * combox.[ch]:
+ * freebrowser.[ch]: ensure that the formatting conforms to xforms
+ style. Add all major authors.
+
+ combox.c (fl_addto_combox): squash bug in initial selection
+ of the first line of the browser.
+
2003-04-03 Angus Leeming <leeming@lyx.org>
* freebrowser.[ch] (fl_get_freebrowser_browser): removed spurious
* Licence details can be found in the file COPYING.
*
* \author Alejandro Aguilar Sierra
+ * \author Lars Gullik Bjønnes
+ * \author Jean-Marc Lasgouttes
* \author Angus Leeming
*
* Full author contact details are available in file CREDITS
static void attrib_change(COMBOX_SPEC * sp);
-FL_OBJECT * fl_create_combox(FL_COMBOX_TYPE type,
- FL_Coord x, FL_Coord y, FL_Coord w, FL_Coord h,
- char const * label)
+FL_OBJECT *
+fl_create_combox(FL_COMBOX_TYPE type,
+ FL_Coord x, FL_Coord y, FL_Coord w, FL_Coord h,
+ char const * label)
{
FL_OBJECT * ob;
FL_OBJECT * button;
}
-FL_OBJECT * fl_add_combox(FL_COMBOX_TYPE type,
- FL_Coord x, FL_Coord y, FL_Coord w, FL_Coord h,
- char const * label)
+FL_OBJECT *
+fl_add_combox(FL_COMBOX_TYPE type,
+ FL_Coord x, FL_Coord y, FL_Coord w, FL_Coord h,
+ char const * label)
{
FL_OBJECT * ob = fl_create_combox(type, x, y, w, h, label);
COMBOX_SPEC * sp = ob->spec;
}
-void fl_set_combox_browser_height(FL_OBJECT * ob, int bh)
+void
+fl_set_combox_browser_height(FL_OBJECT * ob, int bh)
{
COMBOX_SPEC * sp;
}
-void fl_set_combox_position(FL_OBJECT * ob, FL_COMBOX_POSITION position)
+void
+fl_set_combox_position(FL_OBJECT * ob, FL_COMBOX_POSITION position)
{
COMBOX_SPEC * sp;
}
-void fl_clear_combox(FL_OBJECT * ob)
+void
+fl_clear_combox(FL_OBJECT * ob)
{
COMBOX_SPEC * sp;
FL_OBJECT * browser;
}
-void fl_addto_combox(FL_OBJECT * ob, char const * text)
+void
+fl_addto_combox(FL_OBJECT * ob, char const * text)
{
COMBOX_SPEC * sp;
FL_OBJECT * browser;
}
}
- if (j != 0)
- {
+ if (j != 0) {
line[j] = '\0';
fl_add_browser_line(browser, line);
- }
+ }
/* By default the first item is selected */
- if (!fl_get_browser(browser)) {
- fl_set_object_label(sp->button_chosen, text);
+ if (fl_get_browser_maxline(browser)) {
+ char const * const label = fl_get_browser_line(browser, 1);
+ fl_set_object_label(sp->button_chosen, label);
+ fl_select_browser_line(browser, 1);
set_activation(sp->button_chosen, ACTIVATE);
if (sp->button_state)
set_activation(sp->button_state, ACTIVATE);
}
-void fl_set_combox(FL_OBJECT * ob, int sel)
+void
+fl_set_combox(FL_OBJECT * ob, int sel)
{
COMBOX_SPEC * sp;
FL_OBJECT * browser;
}
-int fl_get_combox(FL_OBJECT * ob)
+int
+fl_get_combox(FL_OBJECT * ob)
{
COMBOX_SPEC * sp;
FL_OBJECT * browser;
}
-char const * fl_get_combox_text(FL_OBJECT * ob)
+char const *
+fl_get_combox_text(FL_OBJECT * ob)
{
COMBOX_SPEC * sp;
}
-char const * fl_get_combox_line(FL_OBJECT * ob, int line)
+char const *
+fl_get_combox_line(FL_OBJECT * ob, int line)
{
COMBOX_SPEC * sp;
FL_OBJECT * browser;
}
-int fl_get_combox_maxitems(FL_OBJECT * ob)
+int
+fl_get_combox_maxitems(FL_OBJECT * ob)
{
COMBOX_SPEC * sp;
FL_OBJECT * browser;
}
-void fl_show_combox_browser(FL_OBJECT * ob)
+void
+fl_show_combox_browser(FL_OBJECT * ob)
{
if (!ob || ob->objclass != FL_COMBOX)
return;
}
-void fl_hide_combox_browser(FL_OBJECT * ob)
+void
+fl_hide_combox_browser(FL_OBJECT * ob)
{
COMBOX_SPEC * sp;
}
-static int combox_pre(FL_OBJECT * ob, int ev, FL_Coord mx, FL_Coord my,
- int key, void *xev)
+static int
+combox_pre(FL_OBJECT * ob, int ev, FL_Coord mx, FL_Coord my, int key,
+ void * xev)
{
COMBOX_SPEC * sp = ob->u_vdata;
FL_OBJECT * combox = sp->combox;
}
-static int combox_post(FL_OBJECT * ob, int ev, FL_Coord mx, FL_Coord my,
- int key, void *xev)
+static int
+combox_post(FL_OBJECT * ob, int ev, FL_Coord mx, FL_Coord my, int key,
+ void * xev)
{
COMBOX_SPEC * sp = ob->u_vdata;
FL_OBJECT * combox = sp->combox;
}
-static int combox_handle(FL_OBJECT * ob, int event, FL_Coord mx, FL_Coord my,
- int key, void * ev)
+static int
+combox_handle(FL_OBJECT * ob, int event, FL_Coord mx, FL_Coord my, int key,
+ void * ev)
{
if (!ob || ob->objclass != FL_COMBOX)
return 0;
}
-static void set_activation(FL_OBJECT * ob, int activation)
+static void
+set_activation(FL_OBJECT * ob, int activation)
{
switch (activation) {
case ACTIVATE:
}
-static void show_browser(COMBOX_SPEC * sp)
+static void
+show_browser(COMBOX_SPEC * sp)
{
FL_OBJECT * ob = sp->combox;
}
-static void state_cb(FL_OBJECT * ob, long data)
+static void
+state_cb(FL_OBJECT * ob, long data)
{
show_browser(ob->u_vdata);
}
-static void chosen_cb(FL_OBJECT * ob, long data)
+static void
+chosen_cb(FL_OBJECT * ob, long data)
{
show_browser(ob->u_vdata);
}
-static void update_button_chosen(FL_FREEBROWSER * fb, int action)
+static void
+update_button_chosen(FL_FREEBROWSER * fb, int action)
{
COMBOX_SPEC * sp = fb->parent;
}
-static void set_state_label(COMBOX_SPEC * sp, int state)
+static void
+set_state_label(COMBOX_SPEC * sp, int state)
{
char const * const up = "@2<-";
char const * const down = "@2->";
}
-static void attrib_change(COMBOX_SPEC * sp)
+static void
+attrib_change(COMBOX_SPEC * sp)
{
FL_OBJECT * parent = sp->combox;
FL_OBJECT * button = sp->button_chosen;
* \see fl_create_combox() for an explanation of the argument list.
*/
FL_EXPORT FL_OBJECT *
-fl_add_combox(FL_COMBOX_TYPE type,
- FL_Coord x, FL_Coord y, FL_Coord w, FL_Coord h,
+fl_add_combox(FL_COMBOX_TYPE type,
+ FL_Coord x, FL_Coord y, FL_Coord w, FL_Coord h,
char const * label);
/** The combox browser has a default height of 100 pixels. Adjust to suit. */
-FL_EXPORT void fl_set_combox_browser_height(FL_OBJECT * ob, int bh);
+FL_EXPORT void
+fl_set_combox_browser_height(FL_OBJECT * ob, int bh);
/** The browser will be displayed either below or above the button,
* dependent upon \param position.
*/
-FL_EXPORT void fl_set_combox_position(FL_OBJECT * ob,
- FL_COMBOX_POSITION position);
+FL_EXPORT void
+fl_set_combox_position(FL_OBJECT * ob, FL_COMBOX_POSITION position);
/** Empty the browser and the combox, \param ob. */
-FL_EXPORT void fl_clear_combox(FL_OBJECT * ob);
+FL_EXPORT void
+fl_clear_combox(FL_OBJECT * ob);
/** Add a line to the combox browser.*/
-FL_EXPORT void fl_addto_combox(FL_OBJECT * ob, char const * text);
+FL_EXPORT void
+fl_addto_combox(FL_OBJECT * ob, char const * text);
/** Set the combox to return line \param choice of the combox browser. */
-FL_EXPORT void fl_set_combox(FL_OBJECT * ob, int choice);
+FL_EXPORT void
+fl_set_combox(FL_OBJECT * ob, int choice);
/** \return the currently selected line of the combox browser. */
-FL_EXPORT int fl_get_combox(FL_OBJECT * ob);
+FL_EXPORT int
+fl_get_combox(FL_OBJECT * ob);
/** \return the contents of the combox.
* (Also the contents of currently selected line of the combox browser.)
*/
-FL_EXPORT char const * fl_get_combox_text(FL_OBJECT * ob);
+FL_EXPORT char const *
+fl_get_combox_text(FL_OBJECT * ob);
/** \return the contents of \param line of the combox browser. */
-FL_EXPORT char const * fl_get_combox_line(FL_OBJECT * ob, int line);
+FL_EXPORT char const *
+fl_get_combox_line(FL_OBJECT * ob, int line);
/** \return the number of items in the combox browser. */
-FL_EXPORT int fl_get_combox_maxitems(FL_OBJECT * ob);
+FL_EXPORT int
+fl_get_combox_maxitems(FL_OBJECT * ob);
/** Show the browser */
-void fl_show_combox_browser(FL_OBJECT * ob);
+FL_EXPORT void
+fl_show_combox_browser(FL_OBJECT * ob);
/** Hide the browser */
-void fl_hide_combox_browser(FL_OBJECT * ob);
+FL_EXPORT void
+fl_hide_combox_browser(FL_OBJECT * ob);
#if defined(__cplusplus)
}
#endif
-#endif
+#endif /* not FL_COMBOX_H */
* Licence details can be found in the file COPYING.
*
* \author Alejandro Aguilar Sierra
+ * \author Lars Gullik Bjønnes
+ * \author Jean-Marc Lasgouttes
* \author Angus Leeming
*
* Full author contact details are available in file CREDITS
static int peek_event(FL_FORM * form, void * xev);
-FL_FREEBROWSER * fl_create_freebrowser(void * parent)
+FL_FREEBROWSER *
+fl_create_freebrowser(void * parent)
{
FL_FORM * current_form = fl_current_form;
FL_FREEBROWSER * fb = fl_calloc(1, sizeof(FL_FREEBROWSER));
}
-void fl_free_freebrowser(FL_FREEBROWSER * fb)
+void
+fl_free_freebrowser(FL_FREEBROWSER * fb)
{
if (!fb)
return;
}
-void fl_show_freebrowser(FL_FREEBROWSER * fb,
- FL_Coord x, FL_Coord y, FL_Coord w, FL_Coord h)
+void
+fl_show_freebrowser(FL_FREEBROWSER * fb,
+ FL_Coord x, FL_Coord y, FL_Coord w, FL_Coord h)
{
int tmp;
int const pos = fl_get_browser(fb->browser);
}
-void fl_hide_freebrowser(FL_FREEBROWSER * fb)
+void
+fl_hide_freebrowser(FL_FREEBROWSER * fb)
{
XUngrabPointer(fl_get_display(), 0);
XFlush(fl_get_display());
}
-static void browser_cb(FL_OBJECT * ob, long data)
+static void
+browser_cb(FL_OBJECT * ob, long data)
{
FL_FREEBROWSER * fb = ob->u_vdata;
fl_hide_freebrowser(fb);
}
-static int peek_event(FL_FORM * form, void * ev)
+static int
+eventWithinObj(XEvent * xev, FL_OBJECT * ob)
+{
+ int result = 0;
+ if (xev && ob) {
+ int const xev_x = (int)(xev->xbutton.x);
+ int const xev_y = (int)(xev->xbutton.y);
+ int const ob_x = (int)(ob->x);
+ int const ob_y = (int)(ob->y);
+ int const ob_w = (int)(ob->w);
+ int const ob_h = (int)(ob->h);
+
+ int const dx = xev_x - ob_x;
+ int const dy = xev_y - ob_y;
+
+ /* result is true if the event occurred within the ob */
+ result = !(dx < 0 || dx > ob_w || dy < 0 || dy > ob_h);
+ }
+ return result;
+}
+
+
+static int
+peek_event(FL_FORM * form, void * ev)
{
XEvent * xev = ev;
FL_FREEBROWSER * fb = form->u_vdata;
fb->last_printable = 0;
fl_hide_tooltip();
- if (xev->type == ButtonPress &&
- ((int)(xev->xbutton.x) - (int)(browser->x) < 0 ||
- (int)(xev->xbutton.x) - (int)(browser->x) > (int)(browser->w) ||
- (int)(xev->xbutton.y) - (int)(browser->y) < 0 ||
- (int)(xev->xbutton.y) - (int)(browser->y) > (int)(browser->h))) {
+ if (xev->type == ButtonPress && !eventWithinObj(xev, browser)) {
fl_hide_freebrowser(fb);
return 1;
}
} FL_FREEBROWSER;
-/** A function to create a freebrowser widget, "owned" by widget \param parent.
- */
-FL_EXPORT FL_FREEBROWSER * fl_create_freebrowser(void * parent);
+/** A function to create a freebrowser widget, "owned" by \param parent. */
+FL_EXPORT FL_FREEBROWSER *
+fl_create_freebrowser(void * parent);
-FL_EXPORT void fl_free_freebrowser(FL_FREEBROWSER *);
+/** Free all memory allocated to \param ptr and to its components. */
+FL_EXPORT void
+fl_free_freebrowser(FL_FREEBROWSER * ptr);
/** \param abs_x, \param abs_y are the coordinates of the top left corner
* of the browser relative to the top left hand corner of the _screen_.
* \param w, \param h are the browser dimensions.
*/
-FL_EXPORT void fl_show_freebrowser(FL_FREEBROWSER *,
- FL_Coord abs_x, FL_Coord abs_y,
- FL_Coord w, FL_Coord h);
+FL_EXPORT void
+fl_show_freebrowser(FL_FREEBROWSER *,
+ FL_Coord abs_x, FL_Coord abs_y, FL_Coord w, FL_Coord h);
-FL_EXPORT void fl_hide_freebrowser(FL_FREEBROWSER *);
+FL_EXPORT void
+fl_hide_freebrowser(FL_FREEBROWSER *);
#if defined(__cplusplus)
}
#endif
-#endif
+#endif /* not FL_FREEBROWSER_H */