int setDASource( PtWidget_t *widget, ApInfo_t *apinfo, PtCallbackInfo_t *cbinfo )
{
	PtWidget_t *parent;
	PtArg_t arg;
	int daNum;
	int source;
	int i;

	/* eliminate 'unreferenced' warnings */
	widget = widget, apinfo = apinfo, cbinfo = cbinfo;

	/* get the widget's group */
	parent = PtWidgetParent(widget);

	/* get the da number from the group */
	PtSetArg(&arg, Pt_ARG_USER_DATA, 0, 0);
	PtGetResources(parent, 1, &arg);
	daNum = *(int *)arg.value;

	/* figure out which source was chosen */
	for(i = 0; i < 9; i++) {
		if(ApName(widget) == daSourceToggles[i]) source = i;
	}

	if(cbinfo->reason == Pt_CB_ARM) {
		da[daNum].m_da_source = source;
	}
	else if(cbinfo->reason == Pt_CB_DISARM) {
		da[daNum].m_da_source = NULLI;
	}

	da_cntrl_1(daNum, NULLI, NULLI);

	return( Pt_CONTINUE );
}
int daConvDialogSet( PtWidget_t *widget, ApInfo_t *apinfo, PtCallbackInfo_t *cbinfo )
{
	PtArg_t args[2];
	int *pDaNum;
	int *value;
	int daNum;

	/* eliminate 'unreferenced' warnings */
	widget = widget, apinfo = apinfo, cbinfo = cbinfo;

	/* get the status of the on-off switch */
	PtSetArg(&args[0], Pt_ARG_ONOFF_STATE, &value, 0);
	PtSetArg(&args[1], Pt_ARG_USER_DATA, &pDaNum, 0);
	PtGetResources(widget, 2, args);
	daNum = *pDaNum;

	if(*value) {
		PtSetArg(&args[0], Pt_ARG_TEXT_STRING, "Dialog Enabled", 0);
		da[daNum].m_da_menu = 1;
	}
	else {
		PtSetArg(&args[0], Pt_ARG_TEXT_STRING, "Dialog Disabled", 0);
		da[daNum].m_da_menu = 0;
	}
	PtSetResources(widget, 1, args);

	daDialogItemEnable(daNum);

	da_cntrl_1(daNum, NULLI, NULLI);
	da_mode(daNum, NULLI);
	da_offset(daNum, NULLI);

	return( Pt_CONTINUE );
}
Beispiel #3
0
int setDir( PtWidget_t *widget, ApInfo_t *apinfo, PtCallbackInfo_t *cbinfo )
{
	PtArg_t args[1];
	char *string;

	/* eliminate 'unreferenced' warnings */
	widget = widget, apinfo = apinfo, cbinfo = cbinfo;

	/* get the directory */
	PtSetArg(&args[0], Pt_ARG_TEXT_STRING, &string, 0);
	PtGetResources(widget, 1, args);

	/* set the directory part of the file name */
	PtSetArg(&args[0], Pt_ARG_TEXT_STRING, string, 0);
	PtSetResources(ABW_fileSelFileName, 1, args);

	/* set the root directory of the file selection widget */
	PtSetArg(&args[0], Pt_ARG_FS_ROOT_DIR, string, 0);
	PtSetResources(ABW_fileSelFileList, 1, args);

	/* save the new directory */
	strcpy(rootDir, string);

	return( Pt_CONTINUE );
}
Beispiel #4
0
int pageLabelTextProc(PtWidget_t *widget, ApInfo_t *apinfo, PtCallbackInfo_t *cbinfo)
{
	PtArg_t args[1];
	RASTER *rasters;
	PAGE *thisPage;
	char *string;

	/* eliminate 'unreferenced' warnings */
	widget = widget, apinfo = apinfo, cbinfo = cbinfo;

	/* get a pointer to the rasters structure */
	rasters = getRasters();

	/* figure out this raster page */
	thisPage = getRasterPage(rasters->curPageIndx);
	
	/* the widget's value and assign it to the page label text variable */
	PtSetArg(&args[0], Pt_ARG_TEXT_STRING, &string, 0);
	PtGetResources(widget, 1, args);
	if((strlen(string) > 0) && (strlen(string) < 128)) {
		thisPage->labelFlag = 1;
		strcpy(thisPage->pageLabel.label, string);
		thisPage->pageLabel.label[127] = 0;	/* force NULL terminator */
	}
	else {
		thisPage->labelFlag = 0;
		strcpy(thisPage->pageLabel.label, "");
	}

	return( Pt_CONTINUE );
}
int initStateDebugDialog( PtWidget_t *link_instance, ApInfo_t *apinfo, PtCallbackInfo_t *cbinfo )
{
	PtWidget_t *widget;
	PtArg_t arg;
	int stateIndex;

	/* eliminate 'unreferenced' warnings */
	link_instance = link_instance, apinfo = apinfo, cbinfo = cbinfo;

	/* get the widget that initiated the link callback */
	widget = ApWidget(cbinfo);

	/* make sure that the dialog has not been destroyed */
	if(PtWidgetFlags(widget) & Pt_DESTROYED) {
		return( Pt_CONTINUE );
	}

	/* get the state index from the buttons user data */
	PtSetArg(&arg, Pt_ARG_USER_DATA, 0, 0);
	PtGetResources(widget, 1, &arg);
	stateIndex = *(int *)arg.value;

	/* set the text of the title widget */
	PtSetArg(&arg, Pt_ARG_WINDOW_TITLE, snames[stateIndex]->statename, 0);
	PtSetResources(ABW_stateDebugDialog, 1, &arg);

	/* initialize the widgets in the state dialog */
	stateDebugDialogSetUser(stateIndex);

	return( Pt_CONTINUE );
}
int switchDebug( PtWidget_t *widget, ApInfo_t *apinfo, PtCallbackInfo_t *cbinfo )
{
	PtArg_t args[2];
	int *value;

	extern int errprt;

	/* eliminate 'unreferenced' warnings */
	widget = widget, apinfo = apinfo, cbinfo = cbinfo;

	/* get the value of the widget */
	PtSetArg(&args[0], Pt_ARG_ONOFF_STATE, &value, 0);
	PtGetResources(widget, 1, &args[0]);

	/* change the text of the widget to reflect current state */
	if(*value) {
		PtSetArg(&args[0], Pt_ARG_TEXT_STRING, "Debug\nOn", 0);
		PtSetArg(&args[1], Pt_ARG_FILL_COLOR, Pg_GREEN, 0);
		PtSetResources(widget, 2, args);
		errprt = 1;

		/* create a stateDebugWindow if switch is on */
		if(!debugWindow) {
			debugWindow = ApCreateModule(ABM_stateDebugWindow, widget, cbinfo);
		}

		/* enable the debugging timer */
		PtSetArg(&args[0], Pt_ARG_TIMER_INITIAL, 15, 0);
		PtSetResources(ABW_stateDebugTimer, 1, &args[0]);
	}
	else {
		PtSetArg(&args[0], Pt_ARG_TEXT_STRING, "Debug\nOff", 0);
		PtSetArg(&args[1], Pt_ARG_FILL_COLOR, Pg_RED, 0);
		PtSetResources(widget, 2, args);
		errprt = 0;
		
		/* destroy the stateDebugWindow if it is displayed */
		if(debugWindow) {
			PtDestroyWidget(debugWindow);
			debugWindow = (PtWidget_t *)NULL;
		}
		if(debugDialog) {
			PtDestroyWidget(debugDialog);
			debugDialog = (PtWidget_t *)NULL;
		}

		/* disable the debugging timer */
		PtSetArg(&args[0], Pt_ARG_TIMER_INITIAL, 0, 0);
		PtSetResources(ABW_stateDebugTimer, 1, &args[0]);
	}

	return( Pt_CONTINUE );
}
int daMenuOverRide( PtWidget_t *widget, ApInfo_t *apinfo, PtCallbackInfo_t *cbinfo )
{
	PtArg_t arg;
	int daNum;

	/* eliminate 'unreferenced' warnings */
	widget = widget, apinfo = apinfo, cbinfo = cbinfo;

	/* get the da number from the widget */
	PtSetArg(&arg, Pt_ARG_USER_DATA, 0, 0);
	PtGetResources(widget, 1, &arg);
	daNum = *(int *)arg.value;

	/* determin which of the override buttons initiated this callback */
	if(ApName(widget) == ABN_daSourceNumOvrRide) {
		if(cbinfo->reason == Pt_CB_ARM) {
			daMenuOvrRides[daNum][0] = 1;
			da[daNum].m_da_src_num = daSourceNumbs[daNum];
		}
		else if(cbinfo->reason == Pt_CB_DISARM) {
			daMenuOvrRides[daNum][0] = 0;
			da[daNum].m_da_src_num = NULLI;
		}
		da_cntrl_1(daNum, NULLI, NULLI);
	}
	else if(ApName(widget) == ABN_daOutputOvrRide) {
		if(cbinfo->reason == Pt_CB_ARM) {
			daMenuOvrRides[daNum][1] = 1;
			da[daNum].m_da_val = daOutputs[daNum];
		}
		else if(cbinfo->reason == Pt_CB_DISARM) {
			daMenuOvrRides[daNum][1] = 0;
			da[daNum].m_da_val = NULLI;
		}
		da_set_1(daNum, NULLI);
	}
	else if(ApName(widget) == ABN_daOffsetOvrRide) {
		if(cbinfo->reason == Pt_CB_ARM) {
			daMenuOvrRides[daNum][2] = 1;
			da[daNum].m_da_offset = daOffsets[daNum];
		}
		else if(cbinfo->reason == Pt_CB_DISARM) {
			daMenuOvrRides[daNum][2] = 0;
			da[daNum].m_da_offset = NULLI;
		}
		da_offset(daNum, NULLI);
	}

	return( Pt_CONTINUE );
}
Beispiel #8
0
int openFile( PtWidget_t *widget, ApInfo_t *apinfo, PtCallbackInfo_t *cbinfo )
{
	PtArg_t args[1];
	int *fileFlag;
	char *fileName;

	/* eliminate 'unreferenced' warnings */
	widget = widget, apinfo = apinfo, cbinfo = cbinfo;

	/* get the type of file to open */
	PtSetArg(&args[0], Pt_ARG_USER_DATA, &fileFlag, sizeof(int));
	PtGetResources(widget, 1, args);

	/* get the file name from the text widget */
	PtSetArg(&args[0], Pt_ARG_TEXT_STRING, &fileName, 0);
	PtGetResources(ABW_fileSelFileName, 1, args);

	switch(*fileFlag) {
	case ROOT_FILE_READ:
		readRoot(fileName);

		/* save the name of the root file in the proc table for rex session */
		strncpy(myptp->p_root, fileName, P_LROOTNAME);
		break;
	case ROOT_FILE_WRITE:
		writeRoot(fileName);

		/* save the name of the root file in the proc table for rex session */
		strncpy(myptp->p_root, fileName, P_LROOTNAME);
		break;
	case RASTER_FILE_SAVE:
		saveRaster(fileName);
	default:
		break;
	}
	return( Pt_CONTINUE );
}
Beispiel #9
0
int rowColProc(PtWidget_t *widget, ApInfo_t *apinfo, PtCallbackInfo_t *cbinfo)
{
	PtArg_t args[1];
	PtWidget_t *thisModule;
	RASTER *rasters;
	PAGE *thisPage;
	CELL *thisCell;
	int *value;
	int rowIndxChange;
	int i;

	/* eliminate 'unreferenced' warnings */
	widget = widget, apinfo = apinfo, cbinfo = cbinfo;

	/* get a pointer to the rasters structure */
	rasters = getRasters();

	/* get pointer to the window module that contains this widget */
	thisModule = ApGetInstance(widget);

	/* figure out this raster page */
	thisPage = getRasterPage(rasters->curPageIndx);
	
	/* get the widget's value and assign it to the appropriate variable */
	PtSetArg(&args[0], Pt_ARG_NUMERIC_VALUE, &value, 0);
	PtGetResources(widget, 1, args);
	if(ApName(widget) == ABN_pageRows) {
		/* if the user is redefining the number of rows in a raster,
		 * the row numbers of the cells has to be changed
		 */
		if(*value != thisPage->nRows) {
			rowIndxChange = *value - thisPage->nRows;
			for(i = 0; i < thisPage->nDefCells; i++) {
				thisCell = getRasterCell(thisPage->cellsInfo, i);
				thisCell->rowN += rowIndxChange;
			}
		}
		thisPage->nRows = *value;
	}
	else if(ApName(widget) == ABN_pageCols) thisPage->nCols = *value;

	initCellButtons(thisModule, thisPage, rasters->newRasters);

	return( Pt_CONTINUE );
}
Beispiel #10
0
/*
 * Function     - wgt_gettext()
 *
 * Arguments    - <widget_name> Name of the widget
 *              - <str> Destination string pointer
 *              - <length> Length of the destination buffer
 *
 * Return Value - -1 if length of the destination buffer is not large enough
 */
sint32_t wgt_gettext(const sint32_t widget_name, char * str, uint32_t length)
{
   PtArg_t arg;
   char * buff;

   // Get the string from the widget
   PtSetArg(&arg, Pt_ARG_TEXT_STRING, 0, 0);
   PtGetResources(AbGetABW(widget_name), 1, &arg);
   buff = (char *)arg.value;

   // Copy the string
   if(length < strlen(buff))
      return (-1);
   else
      strcpy(str, buff);

   return (0);
}
Beispiel #11
0
int
axis_change( PtWidget_t *widget, ApInfo_t *apinfo, PtCallbackInfo_t *cbinfo )
{
  PtArg_t args[1];
  unsigned short *newaxis;
  
  // index is Pt_ARG_CBOX_SEL_ITEM
  /* eliminate 'unreferenced' warnings */
  widget = widget, apinfo = apinfo, cbinfo = cbinfo;
  
  PtSetArg( &args[0], Pt_ARG_CBOX_SEL_ITEM, &newaxis, 0 ); 
  PtGetResources(ABW_axis_selector, 1, args);
  current_axis = *newaxis - 1;
  // fprintf(stderr, "New AXIS : %d\n", current_axis);

  draw_gains();
  return( Pt_CONTINUE );
  
}
int setDAParameters( PtWidget_t *widget, ApInfo_t *apinfo, PtCallbackInfo_t *cbinfo )
{
	PtArg_t args[2];
	int daNum;
	int value;

	/* eliminate 'unreferenced' warnings */
	widget = widget, apinfo = apinfo, cbinfo = cbinfo;

	/* get the da number and value from the widget */
	PtSetArg(&args[0], Pt_ARG_USER_DATA, 0, 0);
	PtSetArg(&args[1], Pt_ARG_NUMERIC_VALUE, 0, 0);
	PtGetResources(widget, 2, args);
	daNum = *(int *)args[0].value;
	value = (int)args[1].value;

	/* figure out which parameter to change */
	if(ApName(widget) == ABN_daSourceNum) {
		daSourceNumbs[daNum] = value;
		if(daMenuOvrRides[daNum][0]) {
			da[daNum].m_da_src_num = daSourceNumbs[daNum];
			da_cntrl_1(daNum, NULLI, NULLI);
		}
	}
	else if(ApName(widget) == ABN_daOutput) {
		daOutputs[daNum] = value;
		if(daMenuOvrRides[daNum][1]) {
			da[daNum].m_da_val = daOutputs[daNum];
			da_set_1(daNum, NULLI);
		}
	}
	else if(ApName(widget) == ABN_daOffset) {
		daOffsets[daNum] = value;
		if(daMenuOvrRides[daNum][2]) {
			da[daNum].m_da_offset = daOffsets[daNum];
			da_offset(daNum, NULLI);
		}
	}

	return( Pt_CONTINUE );
}
Beispiel #13
0
int pageLabelSizeProc(PtWidget_t *widget, ApInfo_t *apinfo, PtCallbackInfo_t *cbinfo)
{
	PtArg_t args[1];
	RASTER *rasters;
	PAGE *thisPage;
	int *value;

	/* eliminate 'unreferenced' warnings */
	widget = widget, apinfo = apinfo, cbinfo = cbinfo;

	/* get a pointer to the rasters structure */
	rasters = getRasters();

	/* figure out this raster page */
	thisPage = getRasterPage(rasters->curPageIndx);
	
	/* get the widget's value and assign it to the appropriate variable */
	PtSetArg(&args[0], Pt_ARG_NUMERIC_VALUE, &value, 0);
	PtGetResources(widget, 1, args);
	thisPage->pageLabel.sz = *value;

	return( Pt_CONTINUE );
}
int messageChoice( PtWidget_t *widget, ApInfo_t *apinfo, PtCallbackInfo_t *cbinfo )
{
	PtArg_t arg;
	long *flags;

	/* eliminate 'unreferenced' warnings */
	widget = widget, apinfo = apinfo, cbinfo = cbinfo;

	/* get the state of the widget */
	PtSetArg(&arg, Pt_ARG_FLAGS, &flags, 0);
	PtGetResources(widget, 1, &arg);

	/* figure out which toggle was selected */
	if(ApName(widget) == ABN_pcmessageToggle) {
		if(*flags & Pt_SET) pcmessageSwitch = YES;
		else pcmessageSwitch = NO;
	}
	else if(ApName(widget) == ABN_pcs_socketToggle) {
		if(*flags & Pt_SET) socketSwitch = YES;
		else socketSwitch = NO;
	}

	return( Pt_CONTINUE );
}
Beispiel #15
0
int pageLabelFontProc(PtWidget_t *widget, ApInfo_t *apinfo, PtCallbackInfo_t *cbinfo)
{
	PtWidget_t *thisModule;
	PtWidget_t *off1;
	PtWidget_t *off2;
	PtArg_t args[1];
	RASTER *rasters;
	PAGE *thisPage;
	void *userData;
	long *flags;
	int font;

	/* eliminate 'unreferenced' warnings */
	widget = widget, apinfo = apinfo, cbinfo = cbinfo;

	off1 = (PtWidget_t *)NULL;
	off2 = (PtWidget_t *)NULL;
	
	/* get a pointer to the rasters structure */
	rasters = getRasters();

	/* get pointer to the window module that contains this widget */
	thisModule = ApGetInstance(widget);

	/* figure out this raster page */
	thisPage = getRasterPage(rasters->curPageIndx);
	
	/* get the flag variable for this widget */
	PtSetArg(&args[0], Pt_ARG_FLAGS, &flags, 0);
	PtGetResources(widget, 1, args);

	/* if this widget's button was pressed,
	 * make sure that the other two widgets' buttons are unpressed
	 */
	if(*flags & Pt_SET) {
		/* get the font */
		PtSetArg(&args[0], Pt_ARG_USER_DATA, &userData, 0);
		PtGetResources(widget, 1, args);
		sscanf(userData, "%d", &font);
		
		/* figure out which button was pressd
		 * so the other two can be unset
		 */
		if(ApName(widget) == ABN_pageLabelDuplex) {
			off1 = ApGetWidgetPtr(thisModule, ABN_pageLabelComplex);
			off2 = ApGetWidgetPtr(thisModule, ABN_pageLabelItalic);
		}
		else if(ApName(widget) == ABN_pageLabelComplex) {
			off1 = ApGetWidgetPtr(thisModule, ABN_pageLabelDuplex);
			off2 = ApGetWidgetPtr(thisModule, ABN_pageLabelItalic);
		}
		else if(ApName(widget) == ABN_pageLabelItalic) {
			off1 = ApGetWidgetPtr(thisModule, ABN_pageLabelDuplex);
			off2 = ApGetWidgetPtr(thisModule, ABN_pageLabelComplex);
		}
		PtSetArg(&args[0], Pt_ARG_FLAGS, Pt_FALSE, Pt_SET);
		PtSetResources(off1, 1, args);
		PtSetResources(off2, 1, args);
	}

	/* if this widget's button was unpressed,
	 * set the default widget's button
	 */
	 else {
		off1 = ApGetWidgetPtr(thisModule, ABN_pageLabelDuplex);
		PtSetArg(&args[0], Pt_ARG_FLAGS, Pt_TRUE, Pt_SET);
		PtSetResources(off1, 1, args);

		PtSetArg(&args[0], Pt_ARG_USER_DATA, &userData, 0);
		PtGetResources(off1, 1, args);
		sscanf(userData, "%d", &font);
	 }
	thisPage->pageLabel.font = font;

	return( Pt_CONTINUE );
}
int setDAMode( PtWidget_t *widget, ApInfo_t *apinfo, PtCallbackInfo_t *cbinfo )
{
	PtWidget_t *parent;
	PtArg_t arg;
	long *flags;
	int daNum;

	/* eliminate 'unreferenced' warnings */
	widget = widget, apinfo = apinfo, cbinfo = cbinfo;

	/* get the widget's group */
	parent = PtWidgetParent(widget);

	/* get the da number from the group */
	PtSetArg(&arg, Pt_ARG_USER_DATA, 0, 0);
	PtGetResources(parent, 1, &arg);
	daNum = *(int *)arg.value;

	/* get the state of this buttons flags */
	PtSetArg(&arg, Pt_ARG_FLAGS, &flags, 0);
	PtGetResources(widget, 1, &arg);

	/* get the name of the toggle button that was pressed */
	if(ApName(widget) == ABN_daDirectToggle) {
		if(*flags & Pt_SET) {
			da[daNum].m_da_mode = DA_DIRECT;

			PtSetArg(&arg, Pt_ARG_FLAGS, Pt_FALSE, Pt_SET);
			PtSetResources(ABW_daOffConToggle, 1, &arg);
			PtSetResources(ABW_daOffStbyToggle, 1, &arg);
		}
		else {
			da[daNum].m_da_mode = NULLI;
		}
	}
	else if(ApName(widget) == ABN_daOffConToggle) {
		if(*flags & Pt_SET) {
			if(da[daNum].m_da_mode == NULLI) da[daNum].m_da_mode = DA_OFFSET_CONN;
			else da[daNum].m_da_mode |= DA_OFFSET_CONN;

			PtSetArg(&arg, Pt_ARG_FLAGS, Pt_FALSE, Pt_SET);
			PtSetResources(ABW_daDirectToggle, 1, &arg);
		}
		else {
			if(da[daNum].m_da_mode == DA_OFFSET_CONN) da[daNum].m_da_mode = NULLI;
			else da[daNum].m_da_mode &= ~DA_OFFSET_CONN;
		}
	}
	else if(ApName(widget) == ABN_daOffStbyToggle) {
		if(*flags & Pt_SET) {
			if(da[daNum].m_da_mode == NULLI) da[daNum].m_da_mode = DA_OFFSET_STBY;
			else da[daNum].m_da_mode |= DA_OFFSET_STBY;

			PtSetArg(&arg, Pt_ARG_FLAGS, Pt_FALSE, Pt_SET);
			PtSetResources(ABW_daDirectToggle, 1, &arg);
		}
		else {
			if(da[daNum].m_da_mode == DA_OFFSET_STBY) da[daNum].m_da_mode = NULLI;
			else da[daNum].m_da_mode &= ~DA_OFFSET_STBY;
		}
	}

	da_mode(daNum, NULLI);

	return( Pt_CONTINUE );
}
Beispiel #17
0
int cellButtonProc(PtWidget_t *widget, ApInfo_t *apinfo, PtCallbackInfo_t *cbinfo)
{
	PtArg_t args[1];
	PtWidget_t *thisModule;
	PtWidget_t *cellButton;
	RASTER *rasters;
	PAGE *thisPage;
	CELL *thisCell, *lastCell;
	PLOT *thisPlot, *lastPlot;
	int cellButtonName;
	void *userData;
	int RCindex;
	int i, reFlag, reDefIndex;

	/* eliminate 'unreferenced' warnings */
	widget = widget, apinfo = apinfo, cbinfo = cbinfo;

	reDefIndex = 0;
	
	/* get a pointer to the rasters structure */
	rasters = getRasters();

	/* get pointer to the window module that contains this widget */
	thisModule = ApGetInstance(widget);

	/* figure out this raster page */
	thisPage = getRasterPage(rasters->curPageIndx);

	/* get this button's position argument */
	PtSetArg(&args[0], Pt_ARG_USER_DATA, &userData, 0);
	PtGetResources(widget, 1, args);
	sscanf(userData, "%d", &RCindex);

	/* mark the selected button yellow */
	/* first set the fill color of all buttons to grey */
	PtSetArg(&args[0], Pt_ARG_FILL_COLOR, Pg_GREY, 0);
	for(i = 0; i < 64; i++) {
		cellButtonName = getCellButtonName(i);
		cellButton = ApGetWidgetPtr(thisModule, cellButtonName);
		if(!cellButton) continue; /* skip bad widgets */
		PtSetResources(cellButton, 1, args);
	}

	/* now set this button's fill color to yellow */
	PtSetArg(&args[0], Pt_ARG_FILL_COLOR, Pg_YELLOW, 0);
	PtSetResources(widget, 1, args);

	/* first find out if the user is defining a new cell
	 * or redefining an old cell
	 * to do this, compare the position index of each
	 * previously defined cell with that of the selected cell
	 */
	reFlag = 0;
	for(i = 0; i < thisPage->nDefCells; i++) {
		thisCell = getRasterCell(thisPage->cellsInfo, i);
		if(thisCell->RCindex == RCindex) {	/* true if redefining an old cell */
			reFlag++;			/* make the redefine flag non-zero */
			reDefIndex = i;			/* index of cell to be redefined */
			break;				/* quit testing if a previous index matches the selected cell index */
		}
	}

	/* if the redefine flag is not 0, the user is redefining an old cell */
	if(reFlag) {
		thisPage->curCellIndx = reDefIndex;
		thisCell = getRasterCell(thisPage->cellsInfo, thisPage->curCellIndx);
		thisPlot = &thisCell->plotInfo;
	}

	/* otherwise, the user is defining a new cell*/
	if(!reFlag) {
		thisPage->curCellIndx = thisPage->nDefCells;
		thisCell = getRasterCell(thisPage->cellsInfo, thisPage->curCellIndx);
		thisPlot = &thisCell->plotInfo;

		/* set the relative location of this cell on the page */
		thisCell->RCindex = RCindex;
		thisCell->colN = RCindex % 8;
		thisCell->rowN = (thisPage->nRows - 1) - (RCindex / 8);

		/* if this is not the first cell on the page
		 * initialize it with the values of the last cell
		 */
		if(thisPage->curCellIndx) {
			lastCell = getRasterCell(thisPage->cellsInfo, thisPage->curCellIndx - 1);
			lastPlot = &lastCell->plotInfo;
			initPlot(thisPage, thisPlot, lastPlot);
		}
		thisPage->nDefCells++;			/* increment the number of defined cells on this page */
	}

	/* set the button's label */
	setButtonLabel(thisModule, thisCell);

 	initPlotWidgets(thisModule, thisPlot);
 	initGraphWidgets(thisModule, &thisPlot->graph);

	return( Pt_CONTINUE );
}
int initStateDebugWindow( PtWidget_t *link_instance, ApInfo_t *apinfo, PtCallbackInfo_t *cbinfo )
{
	PtWidget_t *scroll;
	PtWidget_t *allGroup;
	PtWidget_t *buttonGroup;
	PhPoint_t sPos;
	ApDBase_t *stateDebugdbase;
	PtArg_t args[6];
	int nArgs;
	int chainIndx;
	int chainStateIndx;
	int i, j;
	char buttonLabel[128];
	char timeStamp[32];

	/* eliminate 'unreferenced' warnings */
	link_instance = link_instance, apinfo = apinfo, cbinfo = cbinfo;

	/* get a pointer to the scroll container */
	scroll = ApGetWidgetPtr(link_instance, ABN_debugScrollContainer);

	/* create a master group widget */
	nArgs = 0;
	PtSetArg(&args[nArgs], Pt_ARG_GROUP_ORIENTATION, Pt_GROUP_HORIZONTAL, 0); ++nArgs;
	PtSetArg(&args[nArgs], Pt_ARG_GROUP_SPACING, 30, 0); ++nArgs;
	allGroup = PtCreateWidget(PtGroup, scroll, nArgs, args);
	
	/* open the state debug variables data base */
	stateDebugdbase = ApOpenDBase(ABM_stateDebugPictures);

	i = 0;
	chainIndx = -1;

	// if this paradigm was built with rebel
	if((snames[0]->rebelFlag1 == REBEL_FLAG1) && (snames[0]->rebelFlag2 == REBEL_FLAG2)) {
		while(snames[i]) {
			j = 0;
			while(nowstate[j].initial_state) {
				if(!strcmp(snames[i]->statename, nowstate[j].initial_state->statename)) {
					chainIndx++;		/* increment chain index */
					chainStateIndx = 0;	/* initial this chain's state index */

					/* create a group widget to hold the state buttons */
					nArgs = 0;
					PtSetArg(&args[nArgs], Pt_ARG_GROUP_ORIENTATION, Pt_GROUP_ASIS, 0); ++nArgs;
					PtSetArg(&args[nArgs], Pt_ARG_ANCHOR_FLAGS, Pt_TRUE,
							 Pt_LEFT_ANCHORED_LEFT|Pt_TOP_ANCHORED_TOP|Pt_BOTTOM_ANCHORED_BOTTOM); ++nArgs;
					PtSetArg(&args[nArgs], Pt_ARG_GROUP_FLAGS, Pt_TRUE, Pt_GROUP_EQUAL_SIZE); ++nArgs;
					PtSetArg(&args[nArgs], Pt_ARG_FILL_COLOR, stateButtonColors[2], 0); ++nArgs;
					buttonGroup = PtCreateWidget(PtGroup, allGroup, nArgs, args);
				}
				j++;
			}

			/* create a set of buttons in the group */
			if(snames[i]->preset) strcpy(buttonLabel, "T");
			else strcpy(buttonLabel, "-");

			if(snames[i]->random) strcat(buttonLabel, "R");
			else strcat(buttonLabel, "-");

			strncat(buttonLabel, snames[i]->statename, 10);
			sprintf(timeStamp, "  %ld", stateDebug[i].time);
			strcat(buttonLabel, timeStamp);
			sPos.x = snames[i]->stateXpos;
			sPos.y = snames[i]->stateYpos;

			nArgs = 0;
			PtSetArg(&args[nArgs], Pt_ARG_TEXT_STRING, buttonLabel, 0); ++nArgs;
			PtSetArg(&args[nArgs], Pt_ARG_FILL_COLOR, stateDebug[i].color, 0); ++nArgs;
			PtSetArg(&args[nArgs], Pt_ARG_USER_DATA, &i, sizeof(int)); ++nArgs;
			chainStates[chainIndx][chainStateIndx].stateButton = ApCreateWidget(stateDebugdbase, "stateButton", sPos.x, sPos.y, nArgs, args);
			chainStates[chainIndx][chainStateIndx].stateIndex = i;
			chainStateIndx++;
		
			i++;
		}
	}
	// if this paradigm was built with spot
	else {
		while(snames[i]) {
			j = 0;
			while(nowstate[j].initial_state) {
				if(!strcmp(snames[i]->statename, nowstate[j].initial_state->statename)) {
					chainIndx++;		/* increment chain index */
					chainStateIndx = 0;	/* initial this chain's state index */

					/* create a group widget to hold the state buttons */
					nArgs = 0;
					PtSetArg(&args[nArgs], Pt_ARG_GROUP_ORIENTATION, Pt_GROUP_VERTICAL, 0); ++nArgs;
					PtSetArg(&args[nArgs], Pt_ARG_GROUP_ROWS_COLS, 24, 0); ++nArgs;
					PtSetArg(&args[nArgs], Pt_ARG_ANCHOR_FLAGS, Pt_TRUE,
							 Pt_LEFT_ANCHORED_LEFT|Pt_TOP_ANCHORED_TOP|Pt_BOTTOM_ANCHORED_BOTTOM); ++nArgs;
					PtSetArg(&args[nArgs], Pt_ARG_GROUP_SPACING, 4, 0); ++nArgs;
					PtSetArg(&args[nArgs], Pt_ARG_GROUP_FLAGS, Pt_TRUE, Pt_GROUP_EQUAL_SIZE); ++nArgs;
					PtSetArg(&args[nArgs], Pt_ARG_FILL_COLOR, stateButtonColors[2], 0); ++nArgs;
					buttonGroup = PtCreateWidget(PtGroup, allGroup, nArgs, args);
				}
				j++;
			}

			/* create a set of buttons in the group */
			if(snames[i]->preset) strcpy(buttonLabel, "T");
			else strcpy(buttonLabel, "-");

			if(snames[i]->random) strcat(buttonLabel, "R");
			else strcat(buttonLabel, "-");

			strncat(buttonLabel, snames[i]->statename, 10);
			sprintf(timeStamp, "  %ld", stateDebug[i].time);
			strcat(buttonLabel, timeStamp);

			nArgs = 0;
			PtSetArg(&args[nArgs], Pt_ARG_TEXT_STRING, buttonLabel, 0); ++nArgs;
			PtSetArg(&args[nArgs], Pt_ARG_FILL_COLOR, stateDebug[i].color, 0); ++nArgs;
			PtSetArg(&args[nArgs], Pt_ARG_USER_DATA, &i, sizeof(int)); ++nArgs;
			chainStates[chainIndx][chainStateIndx].stateButton = ApCreateWidget(stateDebugdbase, "stateButton", 0, 0, nArgs, args);
			chainStates[chainIndx][chainStateIndx].stateIndex = i;
			chainStateIndx++;
		
			i++;
		}
	}

	PtSetArg(&args[0], Pt_ARG_USER_DATA, 0, 0);
	PtGetResources(chainStates[0][0].stateButton, 1, &args[0]);
	ApCloseDBase(stateDebugdbase);

	return( Pt_CONTINUE );
}