/*
* trial_field_manager()
*
* manager for the custom panel items
*/
trial_field_manager()
{
int i,n_varb,status=0;
char name[MAX_LEN_VARB_NAME], *calloc();
static int total_fields=0;
/* initialize data structure for the new dynamical system */
status = trial_init();
/* exit now if the window has not been created */
if (trial_ip == NULL || status != 0) return(status);
/* destroy the custom items */
if (total_fields > 0)
{
for (i=0; i<total_fields; i++)
{
xv_destroy(trial_ip->varb_value[i]);
}
cfree((char *) trial_ip->varb_value);
xv_destroy(trial_ip->setting1);
}
/* find out the number of variables */
n_varb = *((int *) pm(GET, Traj_Ds_Object, Varb_Dim, NULL));
total_fields = n_varb;
/* allocate memory for the array of text fields */
trial_ip->varb_value = (Xv_opaque *) calloc(n_varb, sizeof(Xv_opaque));
if (trial_ip->varb_value == NULL)
{
total_fields = 0;
system_mess_proc(1,"trial_field_manager: Memory allocation error.");
return(-1);
}
/* create the window text fields, and write the label into them */
for(i=0; i<n_varb; i++)
{
trial_ip->varb_value[i] =
trial_win_varb_value_create(trial_ip,trial_ip->pan,i);
pm(GET, Traj_Ds_Object, Varb_Names, i, name, NULL);
xv_set(trial_ip->varb_value[i], PANEL_LABEL_STRING, name, NULL);
}
/* set up the settings item choices */
trial_ip->setting1 =
trial_win_setting1_create(trial_ip, trial_ip->pan, n_varb);
for (i=0; i<n_varb; i++)
{
pm(GET, Traj_Ds_Object, Varb_Names, i, name, NULL);
xv_set(trial_ip->setting1, PANEL_CHOICE_STRING, i, name, NULL);
}
/* make window tall enough */
window_fit(trial_ip->pan);
window_fit(trial_ip->win);
/* write data into the fields */
trial_data_refresh();
return(status);
}