/* $Log: xtext.C,v $ /* Revision 1.5 1994/04/13 21:21:50 newhall /* *** empty log message *** /* * Revision 1.4 1994/03/26 04:37:08 newhall * change all floats to double * */ /* * xtext.c * * This an example of how to use the Text and Paned widgets. * * November 14, 1989 - Chris D. Peterson * * Updated to also demonstrate XtAppAddInput() -- Bruce Irvin 3/8/94 */ /* * $XConsortium: xtext.c,v 1.16 91/05/16 14:56:23 swick Exp $ * * Copyright 1989 Massachusetts Institute of Technology * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided that * the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of M.I.T. not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. M.I.T. makes no representations about the * suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * M.I.T. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL M.I.T. * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #include #include #include #include #include #include #include ////////////////////////////////// #include "../h/visualization.h" ////////////////////////////////// static void ClearText(Widget w,XtPointer text_ptr,XtPointer call_data); static void PrintText(Widget w,XtPointer text_ptr,XtPointer call_data); static void QuitProgram(Widget w,XtAppContext app_con,XtPointer call_data); static void Syntax(XtAppContext app_con,char *call); ////////////////////////////// XtAppContext app_con; Widget toplevel, paned, clear, print, quit, text; Widget getMR; ////////////////////////////// // extern int fprintf(), bcopy(), read(), perror(), printf(); String fallback_resources[] = { "*input: True", "*showGrip: off", "?.?.text.preferredPaneSize: 200", "?.?.text.width: 200", "?.?.text.textSource.editType: edit", "?.?.text.scrollVertical: whenNeeded", "?.?.text.scrollHorizontal: whenNeeded", "?.?.text.autoFill: on", "*clear*label: Clear", "*print*label: Print", "*quit*label: Quit", NULL, }; ///////////////////////////////////////////////////////////// //void fd_input(XtPointer client_data,int *fid,XtInputId *id) //{ // Widget text = (Widget) client_data; // Arg args[1]; // XawTextPosition pos; // XawTextBlock tb; // char buf[10000]; // int nbytes; // // XtSetArg(args[0], XtNinsertPosition, &pos); // XtGetValues(text, args, ONE); // // if ((nbytes = read(*fid, buf, BUFSIZ)) == -1) // perror("fd_input"); // else if (nbytes > 0) { // tb.firstPos = 0; // tb.length = nbytes; // tb.ptr = buf; // tb.format = FMT8BIT; // // if (XawTextReplace(text,pos,pos+nbytes-1,&tb) != XawEditDone) { // fprintf(stderr,"XawTextReplace returned error\n"); // } // // pos += nbytes; // XtSetArg(args[0], XtNinsertPosition, pos); // XtSetValues(text, args, ONE); // } //} // callback routine for FOLD and DATAVALUES int fd_input(int dummy){ Arg args[1]; XawTextPosition pos; XawTextBlock tb; char buf[100]; int i,j,k; int noMetrics,noResources,noBins; int size; double value; XtSetArg(args[0], XtNinsertPosition, &pos); XtGetValues(text, args, ONE); noMetrics = dataGrid.NumMetrics(); noResources = dataGrid.NumResources(); noBins = dataGrid.NumBins(); for(i=0;i < noMetrics; i++) for(j=0;j