VAddButton
Name
VAddButton - adds a Button Item to the list.
Synopsis
VAddButton(win, x, y, w, h, label, proc, type, ID)
Window win;
int x, y, w, h;
char *label;
int (*proc)();
int type;
BUTTON **ID; /*RETURN*/
Description
VAddButton adds a new Button Item to the list of buttons. These buttons
are one of the three types of buttons that can be created within 3dviewnix.
Besides this button, there is the buttons created in the Panel area
(VDisplayPanel), and the buttons created by calling VDrawBoxOrButton.
VAddButton returns the Button at ID. The buttons created by VAddButton are
displayed immediately and are active (will accept mouse button presses).
Please note that VAddButton should not be called for panel buttons, see
VDisplayPanel.
Structures
typedef struct _button {
Window win; /*window in which item resides*/
short type; /*type of button(0=button, 1=toggle, etc..)*/
short x,y; /*location of upper-left corner of item*/
short w; /*width of the item area in fonts*/
short h; /*height of the item area in fonts*/
short label_width; /*width of label in pixels*/
short label_height; /*height of label*/
short label_ascent; /*ascent dimension of font*/
short label_x; /*position of the label*/
short label_y;
short thick; /*thickness of frame*/
short width; /*width of item in pixels*/
short height; /*height of item in pixels*/
int fw,fh; /*size of font*/
char label[150]; /*label of the button item*/
short state; /*indicates if button item is OFF(0) / ON(1)*/
short mode; /*0=RELEASED, 1=PRESSED*/
int (*func)(); /*notify procedure*/
struct _button *next; /*next button item*/
} BUTTON;
Return Value
0 - work successfully.
1 - memory allocation error.
Parameters
win - window containing the Button Item (any window).
x, y - location of the Item within the window; if the location is not
within the window, the buttons are not displayed, but no error is
returned.
w - maximum width of item (label+value) in font_width units.
h - maximum height of item in Fonts x10(>0) or pixels (<0).
label - string representing the label of the Item.
proc - the notify procedure that is called when this button is invoked;
no parameters can be passed to the procedure; if proc is NULL it
is not executed but no error returned.
type - the type of button; it can be button a button(0) or a toggle(1);
buttons work independently, whereas toggle change state of other
related buttons when the state of this button is changed.
ID - address of the Item ID; it is dynamically allocated. It is freed only
when the button is destroyed (VDeleteButton) or if the entire list
of buttons is cleared from memory (VClearButtonList).
Side Effects
A new structure is appended to the Button Item list.
Entry Conditions
VCreateColormap should be called earlier, else VAddButton prints an
error message to the standard error stream, produces a core dump file,
and exits from the current process.
Related Functions
VCheckButtonEvent,
VClearButtonList,
VDeleteButton,
VSetButtonOff,
VSetButtonOn,
VSetButtonLabel,
VSetButtonLoc.