#include "geminc.h" #include "gemprm.h" #include "Nxm.h" #define MAXCOPY 50 #define SPOOL_TBL "printer.tbl" typedef struct { char *listname; /* name in menu */ char *prtname; /* in command */ char color; /* color availability */ char size; /* paper size availability */ } prtRec_t ; /* printer attribute structure */ typedef struct { int n_prt; /* total # of printers */ int select; /* selected printer */ prtRec_t *rec; /* printer attributes */ } prtStr_t; static prtStr_t _prtStr; /* printer info. structure */ static void (*_applPrtFunc)( void ); /* pointer to application print function */ static char _applWin[20]; /* application window name */ /* global widgets */ static Widget _prtW, _copyTxtW; static Widget _colorWid[3]; static Widget _fileTxtW, _framePrt, _frameFil; static Widget _sizeWid1, _sizeWid2; static Widget _oriW1, _oriW2; static Widget _OnePgW, _AllPgW; static int _psOnlyFlg = FALSE; /* printer/PS only flag */ static int _pageMode; /* current/all page flag */ #ifndef NSHARP static int _oriMode; /* paper orientation flag */ static int _sizeMode; /* paper size mode */ static int _colorMode; /* color mode */ static Widget _txtPrtWin; static char _currTxtFileNm[64]; /* current text file to be printed */ static char _currTxtPrtName[64]; /* current text printer name */ #endif static int _curPrtInx; /* index to current printer */ static char _curPrtName[256]; /* name of curent printer */ static int _printFlg; /* print in process flag */ static int _prtStopFlg; /* print process stop flag */ /* * Private functions */ void _prtReadTbl ( void ); void _prtPsSelect ( Widget parent ); void _printerName ( Widget parent ); void _psFileName ( Widget parent ); void _prtNumSelect ( Widget parent ); void _prtColorSelect ( Widget parent ); void _prtSizeSelect ( Widget parent ); void _prtOrientSelect ( Widget parent ); void _prtPageSelect ( Widget parent ); void _prtCtlBtn ( Widget parent ); void _prtSetDefault ( int which ); void _prtCommand ( char *cmd ); void _defaultPrinter ( void ); void _prtPsSelectCb ( Widget, long, XtPointer ); void _prtSizeSelectCb ( Widget, long, XmToggleButtonCallbackStruct *call ); void _prtOrientSelectCb(Widget, long, XmToggleButtonCallbackStruct *call ); void _prtColorSelectCb (Widget, long, XmToggleButtonCallbackStruct *call ); void _prtPageSelectCb ( Widget, long, XtPointer ); void _prtNameCb ( Widget, long, XtPointer ); void _prtOkCb ( Widget, XtPointer, XtPointer ); void _prtCancelCb ( Widget, XtPointer, XtPointer ); void _prtHelpCb ( Widget, XtPointer, XtPointer ); void _printToPs ( char *ps_file ); int _prtSetPSDev ( char *ps_file ); int _prtSetXWPdev ( char *wname ); void _prtSwitchMode ( void ); void NxmPrt_txtPrtCtlBtnCb ( Widget wdgt, XtPointer clnt, XtPointer call ); void NxmPrt_txtPrtDestroyCb( Widget wdgt, XtPointer clnt, XtPointer call ); /************************************************************************ * NxmPrt.c * * * * This module contains functions that creates the print panel. * * * * CONTENTS: * * * * NxmPrt_create() create the print popup module. * * NxmPrt_prtWPopup() pops up the print widget panel. * * NxmPrt_isPrtFlgSet() query printing status flag * * NxmPrt_isPgFlgSet() query printing page status flag * * NxmPrt_stopPrt() set the stop printing flag * * * * _prtReadTbl() read the printer setup table * * _prtPsSelect() create the printer or PS only select box. * * _printerName() create the printer choice option menu. * * _psFileName() create PS file name input field. * * _prtNumSelect() create number of copy field * * _prtColorSelect() create the printer color selection box * * _prtSizeSelect() create the paper size slection box * * _prtOrientSelect() create the orientation slection box * * _prtPageSelect() create the one page/all page selection area * * _prtCtlBtn() create the control buttons for the popup * * _prtSetDefault() set up the default for the popup window * * _prtCommand() generate the printing command * * _defaultPrinter() set the default printer attributes * * * * _prtPsSelectCb() printer/PS_only toggles callback function * * _prtOrientSelectCb() orientation choice toggles callback function * * _prtColorSelectCb() color choice toggles callback function * * _prtSizeSelectCb() paper size toggles callback function * * _prtPageSelectCb() page number choice callback function * * _prtNameCb() printer name option menu callback function * * _prtOkCb() ok button callback function * * _prtCancelCb() cancel button callback function * * _prtHelpCb() help button callback function * * NxmPrt_txtPrtCtlBtnCb() callback for ctl btns of print window * * NxmPrt_txtPrtDestroyCb() callback before destroying the widget * * * * _printToPs() print to a PostScript file * * _prtSetPSDev() set device to PS driver * * _prtSetXWPdev() set device to XWP driver * * _prtSwitchMode() switch between printer and PS mode * ***********************************************************************/ /*=====================================================================*/ Widget NxmPrt_create ( char *wname, Widget parent, void (*print_func)(void) ) /************************************************************************ * NxmPrt_create * * * * This function create the print popup panel * * * * Widget NxmPrt_create( wname, parent, print_func ) * * * * Input parameters: * * wname char* window name * * parent Widget parent widget ID * * *print_func() void application printing function * * * * Output parameters: * * NxmPrt_create Widget ID of the print popup panel * * * ** Log: * * S. Wang/GSC 05/96 * * I. Durham/GSC 05/98 Changed underscore decl. to * * an include * * H. Zeng/SAIC 05/04 do more initialization * ***********************************************************************/ { Widget pane, rc; XmString str; /*---------------------------------------------------------------------*/ strcpy(_applWin, wname); _prtW = XmCreateBulletinBoardDialog(parent, "prtPanel", NULL, 0); str = XmStringCreateLocalized("Printer Setup"); XtVaSetValues(_prtW, XmNnoResize, True, XmNdialogTitle, str, NULL); XmStringFree(str); pane = XtVaCreateManagedWidget("prtpane", xmPanedWindowWidgetClass, _prtW, XmNsashWidth, 1, XmNsashHeight, 1, NULL); _prtPsSelect(pane); _prtReadTbl(); _printerName(pane); _psFileName(pane); _prtNumSelect(pane); rc = XtVaCreateManagedWidget("SelectRc", xmRowColumnWidgetClass, pane, XmNorientation, XmHORIZONTAL, XmNnumColumns, 1, NULL); _prtColorSelect(rc); _prtSizeSelect(rc); _prtOrientSelect(rc); _prtPageSelect(pane); _prtCtlBtn(pane) ; _prtNameCb(NULL, 0, NULL); XmToggleButtonSetState(_OnePgW, True, True); _applPrtFunc = print_func; /* * Initialize the current text printer name. */ #ifndef NSHARP _currTxtPrtName[0] = '\0'; #endif XtRealizeWidget(_prtW); return(_prtW); } /*=====================================================================*/ void NxmPrt_prtWPopup ( void ) /************************************************************************ * NxmPrt_prtWPopup * * * * This function pops up the print panel * * * * void NxmPrt_prtWPopup() * * * * Input parameters: * * Output parameters: * * Return parameters: * * NONE * * * ** Log: * * S. Wang/GSC 05/96 initial coding * * J. Wu/SAIC 01/04 call _prtSwitchMode() * ***********************************************************************/ { XtManageChild(_prtW); _prtSwitchMode (); } /*=====================================================================*/ int NxmPrt_isPrtFlgSet ( void ) /************************************************************************ * NxmPrt_isPrtFlgSet * * * * This function querys the print_in_process flag * * * * int NxmPrt_isPrtFlgSet() * * * * Input parameters: * * Output parameters: * * NONE * * Return parameters: * * NxmPrt_isPrtFlgSet int =1 print flag set, =0 print flag not set* * * ** Log: * * S. Wang/GSC 05/97 initial coding * ***********************************************************************/ { return(_printFlg); } /*=====================================================================*/ int NxmPrt_isPgFlgSet ( void ) /************************************************************************ * NxmPrt_isPgFlgSet * * * * This function querys the page flag status * * * * int NxmPrt_isPgFlgSet() * * * * Input parameters: * * Output parameters: * * NONE * * Return parameters: * * NxmPrt_isPgFlgSet int =1 page flag set, =0 page flag not set * * * ** Log: * * S. Wang/GSC 05/97 initial coding * ***********************************************************************/ { return(_pageMode); } /*=====================================================================*/ void NxmPrt_stopPrt ( void ) /************************************************************************ * NxmPrt_stopPrt * * * * This function sets the stop printing flag to true * * * * void NxmPrt_stopPrt() * * * * Input parameters: * * Output parameters: * * Return parameters: * * NONE * * * ** Log: * * S. Wang/GSC 05/97 * ***********************************************************************/ { _prtStopFlg = -1; } /*=====================================================================*/ void _prtReadTbl ( void ) /************************************************************************ * _prtReadTbl * * * * This function reads the printer setup table. If loading fails * * the application will use only the default printer. * * * * void _prtReadTbl() * * * * Input parameters: * * Output parameters: * * Return parameters: * * NONE * * * ** Log: * * C. Lin/EAI 12/92 * * S. Wang/GSC 05/96 modify and restructured * * S. Schotz/NCEP 03/97 removed win_name from call * * S. Wang/GSC 05/97 rewrite * ***********************************************************************/ { int i, n, iret, ier, open_flg; FILE *fp; char color, size; char def_dir[20]; char listname[256], prtname[256], buffer[256]; /*---------------------------------------------------------------------*/ iret = 0; open_flg = 1; n = 1; strcpy( def_dir, "config" ); fp = cfl_tbop(SPOOL_TBL, def_dir, &ier ); if ( fp == NULL || iret != 0 ) { printf(" Unable to open %s table \n", SPOOL_TBL ); open_flg = 0; } /* * read all the records in the table */ if ( open_flg == 1 ) { while ( !feof(fp) ) { cfl_trln(fp, 256, buffer, &ier); if ( ier == 0 ) n++; } if ( n>1 ) rewind(fp); } _prtStr.n_prt = n; _prtStr.rec = (prtRec_t *)malloc( (size_t)n*sizeof(prtRec_t) ); _defaultPrinter(); if ( open_flg == 1 ) { /* * starts reading in printer info */ for( i=1; iNxmLabel_createFrameLbl * ***********************************************************************/ { long ii; Widget radio_box, pane_fr; Widget frame_co; char *color_list[] = { "Gray", "Black/White", "Color" }; /*---------------------------------------------------------------------*/ frame_co = XtVaCreateManagedWidget("frameCol", xmFrameWidgetClass, parent, NULL); pane_fr = XtVaCreateManagedWidget( "pane_fr", xmPanedWindowWidgetClass, frame_co, XmNsashWidth, 1, XmNsashHeight, 1, XmNx, 10, NULL ); NxmLabel_createFrameLbl("Color", pane_fr, frame_co ); radio_box = XmCreateRadioBox(pane_fr, "colorGray", NULL, 0); for (ii=0;ii<(long)XtNumber(color_list);ii++) { _colorWid[ii] = XtVaCreateManagedWidget(color_list[ii], xmToggleButtonGadgetClass, radio_box, NULL); XtAddCallback(_colorWid[ii], XmNvalueChangedCallback, (XtCallbackProc)_prtColorSelectCb, (XtPointer)ii); } XtManageChild(radio_box); return; } /*=====================================================================*/ void _prtSizeSelect ( Widget parent ) /************************************************************************ * _prtSizeSelect * * * * This function create the paper size selection area * * * * void _prtSizeSelect(parent) * * * * Input parameters: * * parent Widget parent widget ID * * * * Output parameters: * * Return parameters: * * NONE * * * ** Log: * * S. Wang/GSC 05/96 * * G. Krueger/EAI 10/97 NxmFrameLabel->NxmLabel_createFrameLbl * ***********************************************************************/ { Widget pane_fr, radio_box; Widget size_fm; /*---------------------------------------------------------------------*/ size_fm = XtVaCreateManagedWidget("frameSize", xmFrameWidgetClass, parent, NULL); pane_fr = XtVaCreateManagedWidget( "pane_fr", xmPanedWindowWidgetClass, size_fm, XmNsashWidth, 1, XmNsashHeight, 1, XmNx, 10, NULL ); NxmLabel_createFrameLbl("Paper_Size", pane_fr, size_fm ); radio_box = XmCreateRadioBox( pane_fr, "size", NULL, 0 ); _sizeWid1 = XtVaCreateManagedWidget("8.5x11", xmToggleButtonGadgetClass, radio_box, NULL); XtAddCallback(_sizeWid1, XmNvalueChangedCallback, (XtCallbackProc)_prtSizeSelectCb, (XtPointer)1); _sizeWid2 = XtVaCreateManagedWidget("11x17", xmToggleButtonGadgetClass, radio_box, NULL); XtAddCallback(_sizeWid2, XmNvalueChangedCallback, (XtCallbackProc)_prtSizeSelectCb, (XtPointer)2); XtManageChild(radio_box); return; } /*=====================================================================*/ void _prtOrientSelect ( Widget parent ) /************************************************************************ * _prtOrientSelect * * * * This function create the oriention selection area * * * * void _prtOrientSelect(parent) * * * * Input parameters: * * parent Widget parent widget ID * * * * Output parameters: * * Return parameters: * * NONE * * * ** Log: * * S. Wang/GSC 05/96 * * G. Krueger/EAI 10/97 NxmFrameLabel->NxmLabel_createFrameLbl * ***********************************************************************/ { Widget frame_or, radio_box, pane_fr; /*---------------------------------------------------------------------*/ frame_or = XtVaCreateManagedWidget("frameOri", xmFrameWidgetClass, parent, NULL); pane_fr = XtVaCreateManagedWidget( "pane_fr", xmPanedWindowWidgetClass, frame_or, XmNsashWidth, 1, XmNsashHeight, 1, XmNx, 10, NULL ); NxmLabel_createFrameLbl("Orientation", pane_fr, frame_or ); radio_box = XmCreateRadioBox(pane_fr, "orient", NULL, 0); _oriW1 = XtVaCreateManagedWidget("Landscape", xmToggleButtonGadgetClass, radio_box, NULL); XtAddCallback(_oriW1, XmNvalueChangedCallback, (XtCallbackProc)_prtOrientSelectCb, (XtPointer)1); _oriW2 = XtVaCreateManagedWidget("Portrait", xmToggleButtonGadgetClass, radio_box, NULL); XtAddCallback(_oriW2, XmNvalueChangedCallback, (XtCallbackProc)_prtOrientSelectCb, (XtPointer)2); XtManageChild(radio_box); return; } /*=====================================================================*/ void _prtPageSelect ( Widget parent ) /************************************************************************ * _prtPageSelect * * * * This function creates current page/all page selection area * * * * void _prtPageSelect(parent) * * * * Input parameters: * * parent Widget parent widget ID * * * * Output parameters: * * Return parameters: * * NONE * * * ** Log: * * S. Wang/GSC 05/97 * * J. Wu/SAIC 01/04 adjust the spacing * ***********************************************************************/ { Widget bb, rowcol; /*---------------------------------------------------------------------*/ /* create a BulletinBoardWidget as the parent for * all the widgets in this panel */ bb = XtVaCreateManagedWidget("bb", xmBulletinBoardWidgetClass, parent, NULL); rowcol = XtVaCreateManagedWidget("Rc", xmRowColumnWidgetClass, bb, XmNorientation, XmHORIZONTAL, XmNradioBehavior, True, XmNnumColumns, 1, XmNspacing, 90, NULL); _OnePgW = XtVaCreateManagedWidget("Current Page", xmToggleButtonGadgetClass, rowcol, NULL); XtAddCallback(_OnePgW, XmNarmCallback, (XtCallbackProc)_prtPageSelectCb, (XtPointer)0); _AllPgW = XtVaCreateManagedWidget("All Pages", xmToggleButtonGadgetClass, rowcol, NULL); XtAddCallback(_AllPgW, XmNarmCallback, (XtCallbackProc)_prtPageSelectCb, (XtPointer)1); return; } /*=====================================================================*/ void _prtCtlBtn ( Widget parent ) /************************************************************************ * _prtCtlBtn * * * * This function create the control buttons * * * * void _prtCtlBtn(parent) * * * * Input parameters: * * parent Widget parent widget ID * * * * Output parameters: * * Return parameters: * * NONE * * * ** Log: * * S. Wang/GSC 05/96 * * S. Wang/GSC 04/97 switch OK and Cancel button * * S. Law/GSC 07/00 added XmStringFree calls * ***********************************************************************/ { Widget bb, button ; XmString str; char *buttonlist[] = { "OK", "Help", "Cancel" }; /*---------------------------------------------------------------------*/ bb = XtVaCreateManagedWidget("bb", xmBulletinBoardWidgetClass, parent, XmNy, 20, NULL); str = XmStringCreateLocalized(buttonlist[0]); button = XtVaCreateManagedWidget("ok_bt", xmPushButtonWidgetClass, bb, XmNwidth, 80, XmNx, 20, XmNlabelString, str, NULL); XmStringFree(str); XtAddCallback(button, XmNactivateCallback, (XtCallbackProc)_prtOkCb, NULL ); str = XmStringCreateLocalized(buttonlist[1]); button = XtVaCreateManagedWidget("help_bt", xmPushButtonWidgetClass, bb, XmNwidth, 80, XmNx, 20+120, XmNlabelString, str, NULL); XmStringFree(str); XtAddCallback(button, XmNactivateCallback, _prtHelpCb, NULL ); str = XmStringCreateLocalized(buttonlist[2]); button = XtVaCreateManagedWidget("cancel_bt", xmPushButtonWidgetClass, bb, XmNwidth, 80, XmNx, 20+2*120, XmNlabelString, str, NULL); XmStringFree(str); XtAddCallback(button, XmNactivateCallback, _prtCancelCb, NULL ); } /*=====================================================================*/ void _prtSetDefault ( int which ) /************************************************************************ * _prtSetDefault * * * * This function set the default selections for the popup window * * * * void _prtSetDefault(which) * * * * Input parameters: * * * * which int index to printer * * * * Output parameters: * * Return parameters: * * NONE * * * ** Log: * * S. Wang/GSC 05/96 * ***********************************************************************/ { int i, j; /*---------------------------------------------------------------------*/ if ( which == 0 ) { for (j=0;j<3;j++) { XtSetSensitive(_colorWid[j], True); } XmToggleButtonSetState(_colorWid[0], False, True); XmToggleButtonSetState(_colorWid[1], True, True); XmToggleButtonSetState(_colorWid[2], False, True); XtSetSensitive(_sizeWid1, True); XtSetSensitive(_sizeWid2, True); XmToggleButtonSetState(_sizeWid1, True, True); XmToggleButtonSetState(_sizeWid2, False, True); XtSetSensitive(_oriW1, True); XtSetSensitive(_oriW2, True); XmToggleButtonSetState(_oriW1, True, True); XmToggleButtonSetState(_oriW2, False, True); } else { for (i=0;i<3;i++) XtSetSensitive(_colorWid[i], True); XmToggleButtonSetState(_colorWid[0], False, True); XmToggleButtonSetState(_colorWid[1], False, True); XmToggleButtonSetState(_colorWid[2], True, True); if ( _prtStr.rec[which].color == 'g' ) { XmToggleButtonSetState(_colorWid[0], True, True); XmToggleButtonSetState(_colorWid[2], False, True); XtSetSensitive(_colorWid[2], False); } if (_prtStr.rec[which].color == 'b' ) { XmToggleButtonSetState(_colorWid[1], True, True); XmToggleButtonSetState(_colorWid[2], False, True); XtSetSensitive(_colorWid[0], False); XtSetSensitive(_colorWid[2], False); } XtSetSensitive(_sizeWid1, True); XtSetSensitive(_sizeWid2, True); XmToggleButtonSetState(_sizeWid1, False, True); XmToggleButtonSetState(_sizeWid2, True, True); if (_prtStr.rec[which].size == 's') { XmToggleButtonSetState(_sizeWid1, True, True); XmToggleButtonSetState(_sizeWid2, False, True); XtSetSensitive(_sizeWid2, False); } XmToggleButtonSetState(_oriW1, True, True); XmToggleButtonSetState(_oriW2, False, True); } } /*=====================================================================*/ void _prtCommand ( char *cmd ) /************************************************************************ * _prtCommand * * * * This function generates the print command * * * * void _prtCommand(cmd) * * * * Input/Output parameters: * * cmd char* print command * * * * Return parameters: * * NONE * * * ** Log: * * S. Wang/GSC 05/96 * * E. Safford/GSC 12/98 use $LP & $LPFLAG, clean up * * S. Jacobs/NCEP 2/99 Added check for default printer * ***********************************************************************/ { strcpy (cmd, "$LP "); if ( strcmp ( _curPrtName, "*" ) != 0 ) { strcat (cmd, getenv("LPFLAG")); strcat (cmd, _curPrtName); } } /*=====================================================================*/ void _defaultPrinter ( void ) /************************************************************************ * _defaultPrinter * * * * This function sets the default printer attributes * * * * void _defaultPrinter() * * * * Input parameters: * * Output parameters: * * Return parameters: * * * ** Log: * * S. Wang/GSC 03/97 * ***********************************************************************/ { char name[250]; /*---------------------------------------------------------------------*/ _prtStr.select = 0; strcpy(name, "DEFAULT"); _prtStr.rec[0].listname = (char *)malloc(strlen(name) +1); strcpy(_prtStr.rec[0].listname, name); strcpy(name, "*"); _prtStr.rec[0].prtname = (char *)malloc(strlen(name) +1); strcpy(_prtStr.rec[0].prtname, name); _prtStr.rec[0].color= '*'; _prtStr.rec[0].size= '*'; } /*=====================================================================*/ /* ARGSUSED */ void _prtPsSelectCb ( Widget wdgt, long which, XtPointer call ) /************************************************************************ * _prtPsSelectCb * * * * This is the callback function for printer/PS only toggle buttons * * * * void _prtPsSelectCb(w, which, call) * * * * Input parameters: * * wdgt Widget calling widget id * * which long index of selection * * call XtPointer calling data * * * * Output parameters: * * Return parameters: * * NONE * * * ** Log: * * S. Wang/GSC 05/96 * * J. Wu/SAIC 01/04 call _prtSwitchMode() * ***********************************************************************/ { XmToggleButtonCallbackStruct *call_struct; /*---------------------------------------------------------------------*/ call_struct = (XmToggleButtonCallbackStruct*)call; if ( call_struct->set == 0 ) return; _psOnlyFlg = (int)which; _prtSwitchMode (); } /*=====================================================================*/ /* ARGSUSED */ void _prtSizeSelectCb ( Widget wdgt, long which, XmToggleButtonCallbackStruct *call ) /************************************************************************ * _prtSizeSelectCb * * * * This is the callbak function for size selection toggles * * * * void _prtSizeSelectCb(w, which, call) * * * * Input parameters: * * wdgt Widget calling widget id * * which long index of selection * * call XmToggleButtonCallbackStruct* calling data * * * * Output parameters: * * Return parameters: * * NONE * * * ** Log: * * S. Wang/GSC 05/96 * ***********************************************************************/ { if (call->set ==0) return; #ifndef NSHARP _sizeMode = (int)which; #endif } /*=====================================================================*/ /* ARGSUSED */ void _prtOrientSelectCb ( Widget wdgt, long which, XmToggleButtonCallbackStruct *call ) /*********************************************************************** * _prtOrientSelectCb * * * * This is the callback function for orientation choice toggles * * * * void _prtOrientSelectCb(w, which, call) * * * * Input parameters: * * w Widget calling widget id * * which long index of selection * * call XmToggleButtonCallbackStruct* calling data * * * * Output parameters: * * Return parameters: * * NONE * * * ** Log: * * S. Wang/GSC 05/96 * ***********************************************************************/ { if (call->set == 0) return; #ifndef NSHARP _oriMode = (int)which; #endif } /*=====================================================================*/ /* ARGSUSED */ void _prtColorSelectCb ( Widget wdgt, long which, XmToggleButtonCallbackStruct *call ) /************************************************************************ * _prtColorSelectCb * * * * This is the callback function for color selection toggles * * * * void _prtColorSelectCb(w, which, call) * * * * Input parameters: * * w Widget calling widget id * * which long index of selection * * call XmToggleButtonCallbackStruct* calling data * * * * Output parameters: * * Return parameters: * * NONE * * * ** Log: * * S. Wang/GSC 05/96 * ***********************************************************************/ { if (call->set ==0) return; #ifndef NSHARP _colorMode = (int)which ; #endif } /*=====================================================================*/ /* ARGSUSED */ void _prtPageSelectCb ( Widget wdgt, long which, XtPointer call ) /*********************************************************************** * _prtPageSelectCb * * * * This is the callback function for current page/all page * * selection toggles. * * * * void _prtPageSelectCb(w, which, call) * * * * Input parameters: * * w Widget calling widget id * * which long index of selection * * call XtPointer calling data * * * * Output parameters: * * Return parameters: * * NONE * * * ** Log: * * S. Wang/GSC 05/96 * ***********************************************************************/ { _pageMode = (int)which; } /*=====================================================================*/ /* ARGSUSED */ void _prtNameCb ( Widget wdgt, long which, XtPointer call ) /************************************************************************ * _prtNameCb * * * * This is the printer name option menu callback function * * * * void _prtNameCb(w, which, call) * * * * Input parameters: * * wdgt Widget calling widget id * * which long index of selection * * call XtPointer never used * * * * Output parameters: * * Return parameters: * * NONE * * * ** Log: * * S. Wang/GSC 05/96 * ***********************************************************************/ { _prtStr.select = (int)which; strcpy(_curPrtName, _prtStr.rec[which].prtname); _curPrtInx = which; _prtSetDefault(_curPrtInx); } /*=====================================================================*/ /* ARGSUSED */ void _prtOkCb ( Widget wdgt, XtPointer clnt, XtPointer call ) /*********************************************************************** * _prtOkCb * * * * This is the callback function for the OK control button * * * * void _prtOkCb(w, data, call) * * * * Input parameters: * * wdgt Widget calling widget id * * clnt XtPointer never used * * call XtPointer never used * * * * Output parameters: * * Return parameters: * * NONE * * * ** Log: * * S. Wang/GSC 05/96 * * S. Wang/GSC 05/97 use _prtStopFlg * * M. Li/GSC 05/01 Add output for XmTextGetString * ***********************************************************************/ { int i, iret, num_copy; char psfile[256]; char cmd[60], prt_cmd[60], numcp[10]; char *str; /*---------------------------------------------------------------------*/ /* * get PostScript file name */ if ( _psOnlyFlg == 1 ) { str = XmTextGetString(_fileTxtW); strcpy (psfile, str); XtFree(str); if (psfile[0] == '\0') { XmTextSetString(_fileTxtW, "ps.plt"); } } else strcpy( psfile, "ps.plt"); /* * get number of copies */ str = XmTextGetString(_copyTxtW); strcpy (numcp, str); XtFree(str); num_copy = atoi(numcp) ; cst_numb( numcp, &num_copy, &iret ) ; if ( iret != 0 ) { num_copy = 1 ; XmTextSetString(_copyTxtW, "1" ) ; } if (num_copy > MAXCOPY) { num_copy = MAXCOPY; } else if (num_copy < 1) { num_copy = 1; } /* * pops down the print panel */ XtUnmanageChild(_prtW); /* * print to PostScript file */ _printToPs(psfile); /* * print to printer if desired */ if ( !_psOnlyFlg && _prtStopFlg != -1 ) { _prtCommand(prt_cmd); sprintf(cmd, "%s %s", prt_cmd, psfile ); for (i=0 ; ireason ) { case XmCR_OK: /* Print button */ ptext = XmStringUnparse (cbs->value, NULL, XmCHARSET_TEXT, XmCHARSET_TEXT, NULL, 0, XmOUTPUT_ALL); strcpy (_currTxtPrtName, ptext); XtFree (ptext); strcpy (cmd, "$LPAODT "); if ( strcasecmp (_currTxtPrtName, "default") != 0 ) { strcat (cmd, getenv("LPAODTFLAG")); strcat (cmd, _currTxtPrtName); strcat (cmd, " "); } strcat (cmd, _currTxtFileNm); system(cmd); XtPopdown( XtParent(_txtPrtWin) ); XtDestroyWidget( _txtPrtWin ); break; case XmCR_CANCEL: /* Cancel */ XtPopdown( XtParent(_txtPrtWin) ); XtDestroyWidget( _txtPrtWin ); break; case XmCR_NO_MATCH: /* No match callback */ NxmWarn_show( wdgt, "Plase select a valid printer!" ); break; default: /* All others */ XtPopdown( XtParent(_txtPrtWin) ); XtDestroyWidget( _txtPrtWin ); break; } } /*=====================================================================*/ /* ARGSUSED */ void NxmPrt_txtPrtDestroyCb ( Widget wdgt, XtPointer clnt, XtPointer call ) /************************************************************************ * NxmPrt_txtPrtDestroyCb * * * * Callback function before Printer Selection window gets destroyed. * * * * void NxmPrt_txtPrtDestroyCb (wdgt, clnt, call) * * * * Input parameters: * * wdgt Widget widget ID * * clnt XtPointer client data * * call XtPointer not used * * * * Output parameters: * * Return parameters: * * NONE * * * ** * * Log: * * H. Zeng/SAIC 06/04 initial coding * ***********************************************************************/ { /* * Delete the temporary file used for printing. */ remove (_currTxtFileNm); } #endif