?? winsmart.c
字號:
#include <phigs.h> /* get HP-PHIGS definitions */#include <X11R5/X11/X.h> /* get common X window definitions */#include <X11/Xlib.h> /* get C routine definitions for X */#include <X11/Xutil.h> /* get X window utilities */#include <X11/XHPlib.h> /* get HP-specific X definitions */#include <stdio.h> /* get standard I/O definitions */main() /* file "WinSmart.c" */{ Display *display; /* X display identifier */ Window parent; /* window id of parent window */ Window window; /* window id of window of interest */ int screen; int LocX; int LocY; unsigned int width; unsigned int height; unsigned int border_width; int depth; unsigned int class; Visual *visual; unsigned long ValueMask; XSetWindowAttributes attributes; int VisualClass; XVisualInfo VisualInfo; Colormap ColourMap; XEvent event; Pint WorkstnID = 1; /* workstation identifier */ Pint ConnID; /* connection identifier */ Pint WorkstnType = POIDDX; /* out/in, dir, dbl bfr, X */ Pint BoxStructure = 1; /* value chosen by user */ static Ppoint SquarePts[4] = {0.0,0.0, 0.0,1.9, 1.9,1.9, 1.9,0.0}; static Ppoint_list Square = {4, SquarePts}; Pstore Store; /* internal storage area */ Pint *ConnectID; /* from "pinq_ws_conn_type" */ Pint SpecificType; /* specific workstation type */ Pdisp_space_size3 WindowSize; /* size of X window */ Plimit Viewport; /* workstation viewport */ Pint Error; /* error-return variable */ float PixelToDC; /* conversion factor */ float DCwidth, DCheight; /* temporary variables */ /*--- open the display and the screen ----------------------------------*/ display = XOpenDisplay(NULL); if (!display) printf("ERROR: Failed to open the display\n"); screen = DefaultScreen(display); /*--- create 8-plane PseudoColor window, child of root -----------------*/ parent = RootWindow(display, screen); /* works on most configs */ LocX = 0; LocY = 0; width = XDisplayWidth(display, screen); height = XDisplayHeight(display, height); border_width = 0; depth = 8; class = InputOutput; VisualClass = PseudoColor; if (!XMatchVisualInfo(display, screen, depth, VisualClass, &VisualInfo)) printf("ERROR: Couldn't find a matching visual\n"); visual = VisualInfo.visual; ValueMask = CWBorderPixel | CWColormap | CWBackPixel; ColourMap = XCreateColormap(display, parent, visual, AllocNone); attributes.colormap = ColourMap; attributes.border_pixel = 0; attributes.background_pixel = 0; window = XCreateWindow(display, parent, LocX, LocY, width, height, border_width, depth, class, visual, ValueMask, &attributes); /*--- capture exposure and resize events -------------------------------*/ XSelectInput(display, window, ExposureMask | StructureNotifyMask | ButtonPressMask); XSync(display, False); popen_phigs((char *) stderr, 0); /* errors go to "stderr" */ /*--- Create a structure with a large red box --------------------------*/ popen_struct(BoxStructure); pset_int_colr_ind(2); pset_int_style(PSTYLE_SOLID); pfill_area(&Square); pclose_struct(); /*--- open the workstation ---------------------------------------------*/ pescape_u5((Pint *) display, (Pint *) window, &ConnID); popen_ws(WorkstnID, (void *) ConnID, WorkstnType); /*--- determine pixel-to-DC conversion factor for resize algorithm -----*/ pcreate_store(&Error, &Store); if (Error) printf("Error %d in pcreate_store.\n", Error), exit(1); pinq_ws_conn_type(WorkstnID, Store, &Error, (void *) &ConnID, &SpecificType); if (Error) printf("Error %d in pinq_ws_conn_type.\n", Error), exit(1); pinq_disp_space_size3(SpecificType, &Error, &WindowSize); if (Error) printf("Error %d in pinq_disp_space_size3.\n", Error), exit(1); PixelToDC = WindowSize.size_dc.size_x / WindowSize.size_raster.size_x; /*--- resize the window down to application size -----------------------*/ width = 600; height = 400; XResizeWindow(display, window, width, height); /*--- map the window, making it visible for the first time -------------*/ XMapWindow(display, window); XSync(display, False); /*--- post the model to the workstation --------------------------------*/ ppost_struct(WorkstnID, BoxStructure, 1.0); /* Loop on X events for the rest of the program. -----------------------*/ /* Regenerate when an exposure event is captured. */ /* Adjust the viewport when a resize event is captured. */ /* Close the workstation and PHIGS when the window is clicked/closed. */ while (1) { XNextEvent(display, &event); switch (event.type) { case Expose: predraw_all_structs(WorkstnID, PFLAG_ALWAYS); break; case ConfigureNotify: DCwidth = (float) event.xconfigure.width * PixelToDC; DCheight = (float) event.xconfigure.height * PixelToDC; Viewport.x_min = 0.0; Viewport.y_min = WindowSize.size_dc.size_y - DCheight; Viewport.x_max = DCwidth; Viewport.y_max = WindowSize.size_dc.size_y; pset_ws_vp(WorkstnID, &Viewport); break; case ButtonPress: pclose_ws(WorkstnID); pclose_phigs(); exit(0); break; default: break; } }}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -