/**********************************************************************/ /* */ /* (c) Copyright, 1997 by Professor Gabriel Robins */ /* */ /* Department of Computer Science, University of Virginia */ /* Charlottesville, VA 22903-2442 (804) 982-2207 */ /* robins@cs.virginia.edu http://www.cs.virginia.edu/~robins/ */ /* */ /* This code may be freely used for all non-commercial purposes. */ /* All copies/portions of this code must contain this header. */ /* */ /**********************************************************************/ /**********************************************************************/ /* Windows.c */ /**********************************************************************/ #include "geometry.h" /**********************************************************************/ void SetUpWindow(int argc, char *argv[] ) { #ifdef MAC CGWindow = NewWindow(0L, &windowBounds, "\pComputational Geometry Workbench", true, documentProc, 0, /* -1L, */ true, 0); dragRect = screenBits.bounds; SetPort(CGWindow); #endif #ifdef SUN if (GRAPHICS == YES) { /* ** Establish a connection to local X server for local display ** */ the_display = XOpenDisplay((char *)NULL); if (the_display == NULL) { fprintf(stderr,"ERROR: could not open a connection to X \n"); exit(1); } the_screen = DefaultScreen(the_display); rootwindow = RootWindow(the_display,the_screen); /********************************************************************** ** Open a window with a x,y pixel location for it upper left corner ** and width and height for its size ** **********************************************************************/ window = XCreateSimpleWindow(the_display, rootwindow, window_left, window_top, window_width,window_height, 1, /* border width */ BlackPixel(the_display, the_screen), /* border color */ WhitePixel(the_display, the_screen));/* background color */ /********************************************************************** ** Set up hints about the window ** **********************************************************************/ the_sizehints = (XSizeHints*) malloc (sizeof(XSizeHints)); the_sizehints -> x = window_left; the_sizehints -> y = window_top; the_sizehints ->width = window_width; the_sizehints ->height = window_height; the_sizehints ->flags = PPosition|PSize; /*program chose */ /********************************************************************** ** Set up standard window preperties ** **********************************************************************/ XSetStandardProperties(the_display,window, "Xlib1", /*window name */ "Xlib1", /*icon name */ (Pixmap) None, /*icon pixmap */ argv,argc, the_sizehints); free (the_sizehints); /* create a graphic context to draw with */ gc = XCreateGC(the_display,window,0L,(XGCValues*) NULL); XSetForeground(the_display,gc,BlackPixel(the_display,the_screen)); /* Make window appear on the screen */ XMapWindow(the_display,window); XFlush(the_display); } #endif } /**********************************************************************/