switch_create_c
status.i4.v = switch_create_c(window_id.i2.v, type.i4.v, row.i4.v,
column.i4.v, height.i4.v, width.i4.v,
text.i1a.r, switch_id.i4.r [,state.i4.v]
[,color.i4.v] [,border_color.i4.v]
[,on_func.f.v] [,on_func_data.g.v]
[,dest.i4p.v] [,off_func.f.v]
[,off_func_data.g.v] [,help_info.s.r]
[,handle.i1a.r])
This routine will create a single latching or momentary switch
in the window indicated by "window_id". All switches in a window
are automatically deleted when the window is deleted.
window_id window ID (use WMNGR_BACKGROUND for background window)
type type of switch
(SWITCH_LATCH -> latching switch,
SWITCH_MOMENTARY -> momentary switch,
SWITCH_STATUS -> status switch which flashes like
a momentary switch and can have its
state changed programmatically like
a latching switch)
row, column window coordinates of the upper left hand
corner of the switch (A value of WMNGR_CENTER for
either coordinate will center the switch in the
window for that plane.)
height height of switch in rows
width width of switch in columns
text null terminated switch text (Note: For multiline
switch labels, successive lines should be separated
by a space which will not be displayed.)
switch_id returned switch ID
(A value of NULL can be passed for this argument
if the switch ID is not needed.)
[state] initial state of the switch (only used for latching
switches)
(SWITCH_ON -> on,
SWITCH_OFF -> off (default))
[color] switch color (default is WHITE)
(constants are in 'cnsparam')
[border_color] border color (default is switch color)
(For a status switch, this is the button press color.)
(constants are in 'cnsparam')
[on_func] address of function to be called upon transition
of the switch to an "on" state (default is NULL)
(called as follows:
on_func(wid.i2.v, on_func_data.g.v, switch_data.s.r)
("switch_data" is a structure of type
SWITCH_ACTION_DATA))
[on_func_data] address of data to be passed to "on_func"
(default is NULL)
[dest] address of 4 byte integer value to be loaded
when the state of the switch changes (default is NULL)
[off_func] address of function to be called when the switch
is turned off (latching switches only) (default is NULL)
(called as follows:
off_func(wid.i2.v, off_func_data.g.v, switch_data.s.r)
("switch_data" is a structure of type
SWITCH_ACTION_DATA))
[off_func_data] address of data to be passed to "off_func"
(default is NULL)
[help_info] context sensitive help callback information
(structure of type HELP_CALLBACK_DATA)
(default is NULL)
[handle] null terminated ASCII handle to be used as an
alternate means of identifying this switch
(default is NULL)
This function returns ACNET status values as follows:
CBS_OK success
CBS_INVARG invalid width, height, or switch type
CBS_NO_WINDOW window doesn't exist
CBS_INVSIZ switch is too big to fit in the window
CBS_NOT_IN_WINDOW switch is not entirely in the requested window
CBS_MEMFAIL failed in allocating dynamic memory
This function requires the following include files:
cnsparam_h, cns_data_structs_h, cbslib_h, acnet_errors_h
Related functions:
switch_create_radio_c, switch_delete_c, switch_window_delete_c,
switch_set_flash_c, switch_read_c, switch_pressed, wn_switch_create_c,
switch_relabel_c, switch_change_case_c, switch_enable_c,
switch_disable_c, switch_set_state_c, switch_text_to_id_c,
window_button_create_c, window_border_button_c
C/C++ usage:
static const char text[] = "Switch";
static const char handle[] = "my_switch";
short window_id;
int status;
int type = SWITCH_LATCH;
int row = WMNGR_CENTER;
int column = WMNGR_CENTER;
int height = 3;
int width = 8;
int switch_id;
int state = SWITCH_OFF;
int color = WHITE;
int border_color = WHITE;
int *dest = (int *) NULL;
void on_func(short window_id, void *dummy,
SWITCH_ACTION_DATA *switch_data);
void off_func(short window_id, void *dummy,
SWITCH_ACTION_DATA *switch_data);
void *on_func_data = (void *) NULL;
void *off_func_data = (void *) NULL;
HELP_CALLBACK_DATA *help_info = (HELP_CALLBACK_DATA *) NULL;
status = switch_create_c(window_id,type,row,column,height,width,
text,&switch_id,state,color,border_color,
on_func,on_func_data,dest,off_func,
off_func_data,help_info,handle);