void CleanupAndExit( Widget w, int exit_code ) { int i; Boolean toggleon; /* status of session toggle buttons */ #ifdef VG_TRACE vg_TRACE_EXECUTION("main: entered CleanupAndExit ..."); #endif /* VG_TRACE */ if (w != NULL) XtDestroyWidget(w); /* * if user is logging in, set type of session desired. No more than * one session type can be selected at a time (if any) ... */ if ( exit_code == NOTIFY_OK ) { XtSetArg(argt[0], XmNset, &toggleon ); XtGetValues(options_failsafe, argt, 1); if ( toggleon ) exit_code = NOTIFY_FAILSAFE; XtGetValues(options_dtlite, argt, 1); if ( toggleon ) exit_code = NOTIFY_DTLITE; XtGetValues(options_dt, argt, 1); if ( toggleon ) exit_code = NOTIFY_DT; if(options_last_dt != NULL) { XtGetValues(options_last_dt, argt, 1); if ( toggleon ) exit_code = NOTIFY_LAST_DT; } for(i = 0; i < appInfo.altDts ; ++i) { if(alt_dts[i] != NULL) { XtGetValues(alt_dts[i], argt, 1); if ( toggleon ) exit_code = NOTIFY_ALT_DTS + i + 1; /* alt desktops start at 1 */ } } } if (!session_selected) exit_code = NOTIFY_OK; CloseCatalog(); ChangeBell("on"); UnsecureDisplay(); XSync (dpyinfo.dpy, 0); XtCloseDisplay(dpyinfo.dpy); exit (exit_code); }
void Quit_Callback ( Widget w, /* Invoking widget */ XtPointer client_data, /* Client's data */ XtPointer call_data ) /* Callback data */ { XtCloseDisplay ( XtDisplay(w) ); exit (0); }
/* * termination of program wrt X; freeing of resources, etc */ void dmTerminateX() { /* Remove the properties on the root window */ if(windowPropertyAtom != (Atom)NULL) XDeleteProperty(display,rootWindow,windowPropertyAtom); XFlush(display); XtDestroyApplicationContext(appContext); XtCloseDisplay(display); }
extern void DtPrintFreeSetupData(DtPrintSetupData *target) { DEBUGOUT(_LtDebug(__FILE__, NULL, "DtPrintFreeSetupData\n")); if (target->print_display && target->print_context) XpDestroyContext(target->print_display, target->print_context); target->print_context = (XPContext)0; if (target->print_display) XtCloseDisplay(target->print_display); target->print_display = (Display *)0; }
/* ARGSUSED */ void ncolor_btnCb ( Widget w, XtPointer clnt, XtPointer call ) /************************************************************************ * ncolor_btnCb * * * * This is the callback for the reset and exit buttons. * * * * ncolor_btnCb ( w, clnt, call ) * * * * Input parameters: * * w Widget widget ID * * clnt XtPointer client data * * call XtPointer callback struct * * * * Output parameters: * * None * * * ** * * Log: * * E. Safford/GSC 01/99 initial coding * * E. Safford/GSC 01/99 modify refresh * ***********************************************************************/ { int which = (long)clnt; Display *dsply; /*---------------------------------------------------------------------*/ if (which) { /* exit */ dsply = XtDisplay(w); XFlush(dsply); XtCloseDisplay(dsply); exit(0); } else { /* reset colors */ NuiColorBarReset(_colorBar); } }
void main(int argc, char **argv) { int i=21,forcer=0; /* init variables. */ Display *p_disp; FILE *fpo; char text[]="MultiSliceRTPsession0"; /* Create the top-level shell widget and initialize the toolkit */ argcount = 0; XtSetArg(args[argcount], XmNallowShellResize, False); argcount++; XtSetArg(args[argcount], XmNtitle, APP_TITLE); argcount++; XtSetArg(args[argcount], XmNiconName, ICON_TITLE); argcount++; top_level = XtAppInitialize(&app, "Slice", NULL, 0, &argc, argv, NULL, args, argcount); theAppName = argv[0]; #include "command_slice.c" /* Create the main window widget */ argcount = 0; /* XtSetArg(args[argcount], XmNwidth , WIDTH); argcount++; XtSetArg(args[argcount], XmNheight, HEIGHT); argcount++; */ main_window = XmCreateRowColumn(top_level, "Main", args, argcount); XtManageChild(main_window); p_disp=XtDisplay(main_window); if(forcer != 1) { /* if(XFetchBytes(p_disp,&i) != NULL){ if(i==21){ fprintf(stderr,"\nOnly one copy of MultiSlice can run at one time...\nslice -forceload will forcibly load a second copy.\nSelf-Destruct Initialised...\nSecond copy destructed...OK\n"); XtCloseDisplay(XtDisplay(main_window));exit(-1);}} i=21; XStoreBytes(p_disp,text,i); */ if((fopen("slicetempyhsTN","r")) != 0){ fprintf(stderr,"\nOnly one copy of MultiSlice RTP can run at one time...\nslice -forceload will forcibly load a second copy if \n the first one was terminated incorrectly.\n"); system("cat slicetempyhsTN"); fprintf(stderr,"\nSelf-destruct initialised...\nSecond copy destructed...OK\n"); XtCloseDisplay(XtDisplay(main_window));exit(-1);}} i=0; strcpy(tempfileold,"slicetempyhsT"); strcpy(tempfilenew,"slicetempyhsT"); addcharac[1]='\0'; strcat(tempfilenew,addcharac); system("echo First copy of MultiSliceRTP started at :- >slicetempyhsTN"); system("date >>slicetempyhsTN"); for(i=0;i<11;i++){yhs_filename[i]=0;squash[i]=0;squash[i+10]=0;} i=0; fprintf(stderr,"\n\n-------------------MultiSlice RTP Status Messages-------------------\n"); fprintf(stderr,"Launching application..."); system("date"); fprintf(stderr,"Load and select file(s) to process...\n"); /* Create the main menu */ create_main_menu(main_window); /* Create the drawing area 1 */ argcount = 0; XtSetArg(args[argcount], XmNwidth , IMAGE_WIDTH); argcount++; XtSetArg(args[argcount], XmNheight, IMAGE_HEIGHT); argcount++; draw_1 = XmCreateDrawingArea(top_level, "draw_1", args, argcount); /* XtManageChild(draw_1); */ /* Create the drawing area 2 */ argcount = 0; XtSetArg(args[argcount], XmNwidth , IMAGE_WIDTH); argcount++; XtSetArg(args[argcount], XmNheight, IMAGE_HEIGHT); argcount++; draw_2 = XmCreateDrawingArea(top_level, "draw_2", args, argcount); /* XtManageChild(draw_2); */ /* Create a watch cursor */ theCursor = XCreateFontCursor(XtDisplay(main_window), XC_watch); /* Create the icon window for the application */ app_icon = XCreateBitmapFromData(XtDisplay(top_level), DefaultRootWindow(XtDisplay(top_level)), icon_bits, icon_width, icon_height); argcount = 0; XtSetArg(args[argcount], XmNiconPixmap, app_icon); argcount++; XtSetValues(top_level, args, argcount); XtAppAddTimeOut(app,2*1000,update_time,NULL); /* Realize all widgets */ XtRealizeWidget(top_level); /* Make some initializations */ setup_display (top_level); create_region_list(®ion_list); /* Event handling loop--keep processing events until done */ XtAppMainLoop(app); }
/* ARGSUSED */ static void Quit(Widget w, XEvent *ev, String *parms, Cardinal *np) { XtCloseDisplay (XtDisplay (text)); exit (0); }
int do_hello_world( int argc, char *argv[], const char *printername, const char *toFile, const char *sample_string ) { XtAppContext app; Widget toplevel, shell, print_shell, hello; long dpi_x = 0L, dpi_y = 0L; char fontname[256]; /* BUG: is this really big enougth ? */ XFontStruct *textFont; XmFontList textFontList; Cardinal n; Arg args[10]; MyPrintCallbackData mpcd; if( doPrint ) { /* Get printer, either by "name" (foobar) or "name@display" (foobar@gaja:5) */ if( XpuGetPrinter(printername, &pdpy, &pcontext) != 1 ) Error(("XpuGetPrinter failure.\n")); /* Configure the print context (paper size, title etc.) * We must do this before creating any Xt widgets - otherwise they will * make wrong assuptions about fonts, resultions etc. ... */ XpuSetJobTitle(pdpy, pcontext, "Simple Xprint XawPrintShell widget demo"); /* Configuration done, set the context */ XpSetContext(pdpy, pcontext); /* Get default printer resolution */ if( XpuGetResolution(pdpy, pcontext, &dpi_x, &dpi_y) != 1 ) { fprintf(stderr, "No default resolution for printer '%s'\n", printername); XpuClosePrinterDisplay(pdpy, pcontext); return(EXIT_FAILURE); } pscreen = XpGetScreenOfContext(pdpy, pcontext); } else { pdpy = XOpenDisplay(NULL); if( !pdpy ) Error(("XOpenDisplay failure.\n")); dpi_x = dpi_y = 0L; pscreen = XDefaultScreenOfDisplay(pdpy); } toplevel = XawOpenApplication(&app, pdpy, pscreen, "xpawprintshelldemo", "XpXawPrintShellDemo", applicationShellWidgetClass, &argc, argv); if( !toplevel ) Error(("XawOpenApplication failure.\n")); if( doPrint ) { n = 0; /* Override any geometry resource settings as XawPrintShell adjusts it's size * to the current page siue when |XawPrintLAYOUTMODE_DRAWABLEAREA| or * |XawPrintLAYOUTMODE_PAGESIZE| are used. */ XtSetArg(args[n], XtNgeometry, "+0+0"); n++; XtSetArg(args[n], XawNlayoutMode, XawPrintLAYOUTMODE_DRAWABLEAREA); n++; print_shell = XtCreatePopupShell("myprintshell", xawPrintShellWidgetClass, toplevel, args, n); /* we're mapping/unmapping at start/end page time */ XtSetMappedWhenManaged(print_shell, False); shell = print_shell; } else { shell = toplevel; } sprintf(fontname, "-adobe-courier-medium-r-normal--40-*-%ld-%ld-*-*-iso8859-1", dpi_x, dpi_y); textFont = XLoadQueryFont(pdpy, fontname); if( !textFont ) { sprintf(fontname, "-*-*-*-*-*-*-*-160-%ld-%ld-*-*-iso8859-1", dpi_x, dpi_y); textFont = XLoadQueryFont(pdpy, fontname); } if( !textFont ) Error(("XLoadQueryFont failure.\n")); textFontList = XmFontListCreate(textFont, XmSTRING_DEFAULT_CHARSET); n = 0; /* Make sure the cursor is off, current Xprt servers do not seem to like * blinking cursors that much... ;-/ */ XtSetArg(args[n], XmNcursorPositionVisible, False); n++; XtSetArg(args[n], XmNvalue, sample_string); n++; XtSetArg(args[n], XmNfontList, textFontList); n++; XtSetArg(args[n], XmNeditMode, XmMULTI_LINE_EDIT); n++; hello = XmCreateText(shell, "mytext", args, n); if( !hello ) Error(("XmCreateText failure.\n")); XtManageChild(hello); XtRealizeWidget(toplevel); XtRealizeWidget(shell); if( doPrint ) { int num_total_rows; short num_visible_rows; int num_pages; pdpy = XtDisplay(toplevel); pdrawable = XtWindow(toplevel); if( !pdpy || !pdrawable ) Error(("No display.\n")); /* Make sure that the Xt machinery is really using the right screen (assertion) */ if( XpGetScreenOfContext(XtDisplay(toplevel), pcontext) != XtScreen(toplevel) ) Error(("Widget's screen != print screen. BAD.\n")); /* Get number of rows visible per page and the number of total rows * in the whole text widget... */ n = 0; XtSetArg(args[n], XmNrows, &num_visible_rows); n++ ; XtSetArg(args[n], XmNtotalLines, &num_total_rows); n++ ; XtGetValues(hello, args, n); /* Take away one row to match the one-line overlapping used by the * "next-page" action proc */ num_visible_rows -= 1; /* Calculate the number of pages */ num_pages = (num_total_rows+num_visible_rows-1) / num_visible_rows; Log(("Printing %d pages (num_total_rows=%d, num_visible_rows=%d)...\n", num_pages, num_total_rows, num_visible_rows)); /* Prepare our own context data for the print shell callbacks */ mpcd.num_pages = num_pages; mpcd.printshell_content = hello; mpcd.num_visible_rows = num_visible_rows; mpcd.appcontext = app; /* Setup the print shell callbacks... */ XtAddCallback(print_shell, XawNpageSetupCallback, PrintOnePageCB, (XtPointer)&mpcd); XtAddCallback(print_shell, XawNstartJobCallback, PrintStartJobCB, NULL); XtAddCallback(print_shell, XawNendJobCallback, PrintEndJobCB, (XtPointer)&mpcd); /* ... and finally start the print job. */ if( toFile ) { printtofile_handle = XpuStartJobToFile(pdpy, pcontext, toFile); if( !printtofile_handle ) { perror("XpuStartJobToFile failure"); Error(("XpuStartJobToFile failure.")); } } else { XpuStartJobToSpooler(pdpy); } } XtAppMainLoop(app); if( doPrint ) { if( toFile ) { if( XpuWaitForPrintFileChild(printtofile_handle) != XPGetDocFinished ) { fprintf(stderr, "%s: Error while printing to file.\n", ProgramName); } } PrintSpoolerCommandResults(pdpy, pcontext); /* We have to use XpDestroyContext() and XtCloseDisplay() instead * of XpuClosePrinterDisplay() to make libXt happy... */ if( pcontext != None ) XpDestroyContext(pdpy, pcontext); XtCloseDisplay(pdpy); } return EXIT_SUCCESS; }
/* ARGSUSED */ static void Quit(Widget w, XtPointer closure, XtPointer callData) { XtCloseDisplay( XtDisplay(w) ); exit(0); }
int main (int argc, char **argv) { XtAppContext appContext; Widget topLevel; Boolean quit = False; // Initialize toolkit topLevel = XtVaAppInitialize (&appContext, "MDI", NULL, 0, &argc, argv, fallbacks, XmNdeleteResponse, XmDO_NOTHING, NULL); Display *dpy = XtDisplay (topLevel); // Add protocols Atom WM_DELETE_WINDOW = XmInternAtom (dpy, "WM_DELETE_WINDOW", False); XmAddWMProtocolCallback (topLevel, WM_DELETE_WINDOW, _destroyCallback, &quit); // Create the MDI canvas XsMDICanvas *canvas = new XsMDICanvas ("MDItest", topLevel); // Create the MDI documents MyDocument *win1 = new MyDocument ("Document", canvas); MyDocument2 *win2 = new MyDocument2 ("Document 2"); // Add documents to MDI canvas canvas->add (win1); canvas->add (win2); // Show the canvas canvas->show ( ); // Realize everything XtRealizeWidget (topLevel); // Let 'er rip XEvent event; while (!quit) { XtAppNextEvent (appContext, &event); XtDispatchEvent (&event); } // Cleanup delete win1; delete win2; delete canvas; // Close the X connection XtDestroyWidget (topLevel); XtCloseDisplay (dpy); XtDestroyApplicationContext (appContext); return (0); }