int Color_Change( PtWidget_t *widget, ApInfo_t *apinfo, PtCallbackInfo_t *cbinfo ) { int i, previous; PtWidget_t* thisWindow; /* eliminate 'unreferenced' warnings */ widget = widget, apinfo = apinfo, cbinfo = cbinfo; thisWindow = ApGetInstance( widget ); if(ApName(widget) == ABN_ButtonRed) { PtSetResource(ApGetWidgetPtr(thisWindow, ABN_ColorRect), Pt_ARG_FILL_COLOR, Pg_RED, 0); } else if(ApName(widget) == ABN_ButtonGreen) { PtSetResource(ApGetWidgetPtr(thisWindow, ABN_ColorRect), Pt_ARG_FILL_COLOR, Pg_GREEN, 0); } else if(ApName(widget) == ABN_ButtonBlue) { PtSetResource(ApGetWidgetPtr(thisWindow, ABN_ColorRect), Pt_ARG_FILL_COLOR, Pg_BLUE, 0); } else if(ApName(widget) == ABN_ButtonPrevious) { previous = -1; for(i = 0; i < WindowCounter; i++) { if(Windows[i] == thisWindow) { previous = i - 1; break; } } if(previous != -1 && Windows[previous]) { base_Color++; if(base_Color >= 5) { base_Color = 0; } //PtSetResource(Windows[previous], Pt_ARG_FILL_COLOR, Colors[base_Color], 0); PtSetResource(ApGetWidgetPtr(Windows[previous], ABN_ColorRect), Pt_ARG_FILL_COLOR, Colors[base_Color], 0); } } return( Pt_CONTINUE ); }
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 ); }
int resetButtons(PtWidget_t *widget, ApInfo_t *apinfo, PtCallbackInfo_t *cbinfo) { PtArg_t args[1]; PtWidget_t *thisModule; PtWidget_t *cellButton; int cellButtonName; int i; /* eliminate 'unreferenced' warnings */ widget = widget, apinfo = apinfo, cbinfo = cbinfo; /* get the module that contains this widget */ thisModule = ApGetInstance(widget); /* reset 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); } return( Pt_CONTINUE ); }
int initDADialog( PtWidget_t *link_instance, ApInfo_t *apinfo, PtCallbackInfo_t *cbinfo ) { PtWidget_t *dialog; PtWidget_t *toggle; PtArg_t args[3]; PtListCallback_t *listData; int daNum; int toggleOverride; int i; char title[16]; void daDialogItemEnable(); /* eliminate 'unreferenced' warnings */ link_instance = link_instance, apinfo = apinfo, cbinfo = cbinfo; /* if this function was called from the list widget */ if(PtWidgetClass(link_instance) == PtList) { if(cbinfo->reason_subtype != Pt_LIST_SELECTION_FINAL) return(Pt_CONTINUE); listData = (PtListCallback_t *)cbinfo->cbdata; sscanf(listData->item, "DA %d", &daNum); dialog = ApGetInstance(link_instance); } else { daNum = 0; PtListSelectPos(ABW_daConvList, 1); dialog = link_instance; } /*set the module's title widget */ sprintf(title, "DA %d", daNum); PtSetArg(&args[0], Pt_ARG_TEXT_STRING, title, 0); PtSetResources(ABW_daDialogLabel, 1, &args[0]); /* set the state of the dialog enable button */ if(da[daNum].m_da_menu) { PtSetArg(&args[0], Pt_ARG_TEXT_STRING, "Dialog Enabled", 0); } else { PtSetArg(&args[0], Pt_ARG_TEXT_STRING, "Dialog Disabled", 0); } PtSetArg(&args[1], Pt_ARG_ONOFF_STATE, da[daNum].m_da_menu, 0); PtSetResources(ABW_daMenuOnOffButton, 2, args); /* set the states of the source toggles */ toggleOverride = -1; for(i = 0; i < 9; i++) { toggle = ApGetWidgetPtr(dialog, daSourceToggles[i]); if(i == da[daNum].m_da_source) { PtSetArg(&args[0], Pt_ARG_FLAGS, Pt_TRUE, Pt_SET); toggleOverride = i; } else { PtSetArg(&args[0], Pt_ARG_FLAGS, Pt_FALSE, Pt_SET); } PtSetResources(toggle, 1, &args[0]); } /* set the states of the mode toggles */ switch(da[daNum].m_da_mode) { case 0: toggleOverride = 0; PtSetArg(&args[0], Pt_ARG_FLAGS, Pt_TRUE, Pt_SET); PtSetResources(ABW_daDirectToggle, 1, &args[0]); PtSetArg(&args[0], Pt_ARG_FLAGS, Pt_FALSE, Pt_SET); PtSetResources(ABW_daOffConToggle, 1, &args[0]); PtSetResources(ABW_daOffStbyToggle, 1, &args[0]); break; case 1: toggleOverride = 1; PtSetArg(&args[0], Pt_ARG_FLAGS, Pt_TRUE, Pt_SET); PtSetResources(ABW_daOffConToggle, 1, &args[0]); PtSetArg(&args[0], Pt_ARG_FLAGS, Pt_FALSE, Pt_SET); PtSetResources(ABW_daDirectToggle, 1, &args[0]); PtSetResources(ABW_daOffStbyToggle, 1, &args[0]); break; case 2: toggleOverride = 2; PtSetArg(&args[0], Pt_ARG_FLAGS, Pt_TRUE, Pt_SET); PtSetResources(ABW_daOffStbyToggle, 1, &args[0]); PtSetArg(&args[0], Pt_ARG_FLAGS, Pt_FALSE, Pt_SET); PtSetResources(ABW_daDirectToggle, 1, &args[0]); PtSetResources(ABW_daOffConToggle, 1, &args[0]); break; default: toggleOverride = -1; PtSetArg(&args[0], Pt_ARG_FLAGS, Pt_FALSE, Pt_SET); PtSetResources(ABW_daDirectToggle, 1, &args[0]); PtSetResources(ABW_daOffConToggle, 1, &args[0]); PtSetResources(ABW_daOffStbyToggle, 1, &args[0]); break; } /* set the states of the menu override buttons */ if(daMenuOvrRides[daNum][0]) PtSetArg(&args[0], Pt_ARG_FLAGS, Pt_TRUE, Pt_SET); else PtSetArg(&args[0], Pt_ARG_FLAGS, Pt_FALSE, Pt_SET); PtSetResources(ABW_daSourceNumOvrRide, 1, &args[0]); if(daMenuOvrRides[daNum][1]) PtSetArg(&args[0], Pt_ARG_FLAGS, Pt_TRUE, Pt_SET); else PtSetArg(&args[0], Pt_ARG_FLAGS, Pt_FALSE, Pt_SET); PtSetResources(ABW_daOutputOvrRide, 1, &args[0]); if(daMenuOvrRides[daNum][2]) PtSetArg(&args[0], Pt_ARG_FLAGS, Pt_TRUE, Pt_SET); else PtSetArg(&args[0], Pt_ARG_FLAGS, Pt_FALSE, Pt_SET); PtSetResources(ABW_daOffsetOvrRide, 1, &args[0]); /* set the numeric values of the override value widgets */ PtSetArg(&args[0], Pt_ARG_NUMERIC_VALUE, daSourceNumbs[daNum], 0); PtSetResources(ABW_daSourceNum, 1, &args[0]); PtSetArg(&args[0], Pt_ARG_NUMERIC_VALUE, daOutputs[daNum], 0); PtSetResources(ABW_daOutput, 1, &args[0]); PtSetArg(&args[0], Pt_ARG_NUMERIC_VALUE, daOffsets[daNum], 0); PtSetResources(ABW_daOffset, 1, &args[0]); /* set the values of the module's "actual" widgets */ /* source name */ i = da[daNum].da_source; PtSetArg(&args[0], Pt_ARG_TEXT_STRING, daSourceNames[i], 0); PtSetResources(ABW_daSourceAct, 1, args); /* mode */ PtSetArg(&args[0], Pt_ARG_NUMERIC_VALUE, da[daNum].da_mode, 0); PtSetResources(ABW_daModeAct, 1, args); /* source number */ PtSetArg(&args[0], Pt_ARG_NUMERIC_VALUE, da[daNum].da_src_num, 0); PtSetResources(ABW_daSourceNumAct, 1, args); /* output value */ PtSetArg(&args[0], Pt_ARG_NUMERIC_VALUE, da[daNum].m_da_val, 0); PtSetResources(ABW_daOutputAct, 1, args); /* offset */ PtSetArg(&args[0], Pt_ARG_NUMERIC_VALUE, (da[daNum].da_offset >> TEN_TO_IC), 0); PtSetResources(ABW_daOffsetAct, 1, args); /* set the da number in all of this module's widgets */ PtSetArg(&args[0], Pt_ARG_USER_DATA, &daNum, sizeof(int)); PtSetResources(ABW_daMenuOnOffButton, 1, &args[0]); PtSetResources(ABW_daSourceGroup, 1, &args[0]); PtSetResources(ABW_daModeGroup, 1, &args[0]); PtSetResources(ABW_daSourceNumOvrRide, 1, &args[0]); PtSetResources(ABW_daSourceNum, 1, &args[0]); PtSetResources(ABW_daOutputOvrRide, 1, &args[0]); PtSetResources(ABW_daOutput, 1, &args[0]); PtSetResources(ABW_daOffsetOvrRide, 1, &args[0]); PtSetResources(ABW_daOffset, 1, &args[0]); daDialogItemEnable(daNum); return( Pt_CONTINUE ); }
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 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 ); }