* Fix compilation with C89 compilers.

* Tell the world that these files belong to LyX.
* change function prototypes to use enums rather than ints.
* add FL_NORMAL_COMBOX to augment FL_DROPLIST_COMBOX.


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6698 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Angus Leeming 2003-04-03 09:21:11 +00:00
parent b12d2c5494
commit 6342052576
6 changed files with 98 additions and 34 deletions

View File

@ -1,3 +1,20 @@
2003-04-03 Angus Leeming <leeming@lyx.org>
* combox.[ch]: add an FL_NORMAL_COMBOX type.
* forms/fdfixc.sed: enable the use of both combox types.
2003-04-03 Angus Leeming <leeming@lyx.org>
* freebrowser.c (peek_event): write C89, not C99, code.
* combox.[ch]:
* freebrowser.[ch]: these files belong to LyX, so say so.
* combox.[ch] (fl_create_combox, fl_add_combox,
fl_set_combox_position): change the function prototypes to use enums
rather than ints.
2003-04-02 Angus Leeming <leeming@lyx.org>
Rename some variables.

View File

@ -1,9 +1,13 @@
/**
* \file combox.c
* This file is part of LyX, the document processor.
* Licence details can be found in the file COPYING.
*
* \author Alejandro Aguilar Sierra
* \author Angus Leeming
*
* Full author contact details are available in file CREDITS
*
* This is a rewrite of Alejandro's C++ Combox class, originally written
* for LyX in 1996. The rewrite turns it into a native xforms widget.
*/
@ -13,7 +17,6 @@
#include "combox.h"
#include "freebrowser.h"
extern void fl_add_child(FL_OBJECT *, FL_OBJECT *);
extern void fl_addto_freelist(void *);
@ -61,7 +64,7 @@ static void set_state_label(COMBOX_SPEC * sp, int state);
static void attrib_change(COMBOX_SPEC * sp);
FL_OBJECT * fl_create_combox(int type,
FL_OBJECT * fl_create_combox(FL_COMBOX_TYPE type,
FL_Coord x, FL_Coord y, FL_Coord w, FL_Coord h,
char const * label)
{
@ -73,6 +76,9 @@ FL_OBJECT * fl_create_combox(int type,
FL_Coord const ws = 0.7 * h;
FL_Coord const xs = x + w - ws;
/* The width of button_chosen */
FL_Coord const wc = (type == FL_DROPLIST_COMBOX) ? (w - ws) : w;
ob = fl_make_object(FL_COMBOX, type, x, y, w, h, label, combox_handle);
ob->align = FL_ALIGN_LEFT;
@ -84,20 +90,23 @@ FL_OBJECT * fl_create_combox(int type,
sp->browser = fl_create_freebrowser(sp);
sp->browser->callback = update_button_chosen;
sp->button_state = fl_add_button(FL_NORMAL_BUTTON, xs, y, ws, h, "");
sp->button_state = 0;
if (type == FL_DROPLIST_COMBOX) {
sp->button_state = fl_add_button(FL_NORMAL_BUTTON, xs, y, ws, h, "");
button = sp->button_state;
fl_set_object_lalign(button, FL_ALIGN_CENTER|FL_ALIGN_INSIDE);
fl_set_object_callback(button, state_cb, 0);
fl_set_object_posthandler(button, combox_post);
fl_set_object_prehandler(button, combox_pre);
set_state_label(sp, COMBOX_CLOSED);
button = sp->button_state;
fl_set_object_lalign(button, FL_ALIGN_CENTER|FL_ALIGN_INSIDE);
fl_set_object_callback(button, state_cb, 0);
fl_set_object_posthandler(button, combox_post);
fl_set_object_prehandler(button, combox_pre);
set_state_label(sp, COMBOX_CLOSED);
set_activation(button, DEACTIVATE);
button->parent = ob;
button->u_vdata = sp;
set_activation(button, DEACTIVATE);
button->parent = ob;
button->u_vdata = sp;
}
sp->button_chosen = fl_add_button(FL_NORMAL_TEXT, x, y, (w - ws), h, "");
sp->button_chosen = fl_add_button(FL_NORMAL_TEXT, x, y, wc, h, "");
button = sp->button_chosen;
fl_set_object_boxtype(button, FL_FRAME_BOX);
@ -113,14 +122,15 @@ FL_OBJECT * fl_create_combox(int type,
}
FL_OBJECT * fl_add_combox(int type,
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;
fl_add_child(ob, sp->button_state);
if (sp->button_state)
fl_add_child(ob, sp->button_state);
fl_add_child(ob, sp->button_chosen);
fl_add_object(fl_current_form, ob);
@ -140,7 +150,7 @@ void fl_set_combox_browser_height(FL_OBJECT * ob, int bh)
}
void fl_set_combox_position(FL_OBJECT * ob, int position)
void fl_set_combox_position(FL_OBJECT * ob, FL_COMBOX_POSITION position)
{
COMBOX_SPEC * sp;
@ -148,7 +158,7 @@ void fl_set_combox_position(FL_OBJECT * ob, int position)
return;
sp = ob->spec;
sp->browser_position = (position == FL_FREEBROWSER_ABOVE) ?
sp->browser_position = (position == FL_COMBOX_ABOVE) ?
FL_FREEBROWSER_ABOVE : FL_FREEBROWSER_BELOW;
set_state_label(sp, COMBOX_CLOSED);
@ -207,7 +217,8 @@ void fl_addto_combox(FL_OBJECT * ob, char const * text)
if (!fl_get_browser(browser)) {
fl_set_object_label(sp->button_chosen, text);
set_activation(sp->button_chosen, ACTIVATE);
set_activation(sp->button_state, ACTIVATE);
if (sp->button_state)
set_activation(sp->button_state, ACTIVATE);
}
}
@ -431,6 +442,10 @@ static void set_state_label(COMBOX_SPEC * sp, int state)
char const * const up = "@2<-";
char const * const down = "@2->";
char const * label = 0;
if (!sp->button_state)
return;
if (sp->browser_position == FL_FREEBROWSER_BELOW) {
label = (state == COMBOX_OPEN) ? up : down;
} else {
@ -451,10 +466,12 @@ static void attrib_change(COMBOX_SPEC * sp)
button->col2 = parent->col2;
button->bw = parent->bw;
button = sp->button_state;
if (sp->button_state) {
button = sp->button_state;
/* The boxtype is not changed */
button->col1 = parent->col1;
button->col2 = parent->col2;
button->bw = parent->bw;
/* The boxtype is not changed */
button->col1 = parent->col1;
button->col2 = parent->col2;
button->bw = parent->bw;
}
}

View File

@ -1,7 +1,12 @@
/**
* \file combox.h
* This file is part of LyX, the document processor.
* Licence details can be found in the file COPYING.
*
* \author Angus Leeming
*
* Full author contact details are available in file CREDITS
*
* A combination of two objects (a button and a browser) is encapsulated to
* get a combobox-like object.
*/
@ -20,10 +25,17 @@ enum {
FL_COMBOX = 200
};
/** The types of combox. At the moment, there's only one. */
enum {
/** The various types of combox. */
typedef enum {
FL_NORMAL_COMBOX,
FL_DROPLIST_COMBOX
};
} FL_COMBOX_TYPE;
/** How the browser should be displayed relative to the buttons. */
typedef enum {
FL_COMBOX_BELOW,
FL_COMBOX_ABOVE
} FL_COMBOX_POSITION;
/** A function to create a combox widget.
* \param type is, as yet, unused. there is only one type of combox.
@ -33,14 +45,16 @@ enum {
* \param label: the widget's label as it appears on the GUI.
*/
FL_EXPORT FL_OBJECT *
fl_create_combox(int type, FL_Coord x, FL_Coord y, FL_Coord w, FL_Coord h,
fl_create_combox(FL_COMBOX_TYPE type,
FL_Coord x, FL_Coord y, FL_Coord w, FL_Coord h,
char const * label);
/** A function to create a combox widget and add it to the parent form.
* \see fl_create_combox() for an explanation of the argument list.
*/
FL_EXPORT FL_OBJECT *
fl_add_combox(int 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. */
@ -49,7 +63,8 @@ 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, int 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);

View File

@ -76,7 +76,13 @@ s/\( fdui->form\)\(.*bgn_form.*\)/\1\2\
# For all lines containing "combox",
# replace "fl_add_choice" with "fl_add_combox"
/combox/ s/fl_add_choice([^,]*/fl_add_combox(FL_DROPLIST_COMBOX/
# Note that only two combox types exist, whilst there are four choice types.
/combox/ {
s/fl_add_choice/fl_add_combox/
s/BROWSER/NORMAL/
s/CHOICE2/COMBOX/
s/CHOICE/COMBOX/
}
# For all lines containing fl_add_choice,

View File

@ -1,9 +1,13 @@
/**
* \file freebrowser.c
* This file is part of LyX, the document processor.
* Licence details can be found in the file COPYING.
*
* \author Alejandro Aguilar Sierra
* \author Angus Leeming
*
* Full author contact details are available in file CREDITS
*
* This is a rewrite of Alejandro's C++ Combox class, originally written
* for LyX in 1996. The rewrite turns it into a native xforms widget.
*/
@ -16,7 +20,6 @@
extern void fl_hide_tooltip(void);
static void browser_cb(FL_OBJECT * ob, long data);
static int peek_event(FL_FORM * form, void * xev);
@ -147,8 +150,9 @@ static int peek_event(FL_FORM * form, void * ev)
}
if (xev->type == KeyPress) {
char s_r[10]; s_r[9] = '\0';
KeySym keysym_return;
char s_r[10];
s_r[9] = '\0';
XLookupString(&xev->xkey, s_r, 10, &keysym_return, 0);
XFlush(fl_get_display());

View File

@ -1,7 +1,12 @@
/**
* \file freebrowser.h
* This file is part of LyX, the document processor.
* Licence details can be found in the file COPYING.
*
* \author Angus Leeming
*
* Full author contact details are available in file CREDITS
*
* A freebrowser is a browser widget in its own form.
* It is used for example to instantiate the drop-down list beneath a
* combox.
@ -15,10 +20,10 @@ extern "C"
{
#endif
enum freebrowser_position {
typedef enum {
FL_FREEBROWSER_BELOW,
FL_FREEBROWSER_ABOVE
};
} FL_FREEBROWSER_POSITION;
typedef struct fl_freebrowser_ {
/** Use this and you'll be told when something happens.