/* * X11 (Unix X Window System) calls that feel useful for BW BASIC * from /usr/include/X11/Xlib.h - angles are in 1/64ths of degrees. * you may also have to include . */ typedef struct { short x, y; } XPoint; /* for 16 bit depth you can use for example: */ typedef unsigned short int PIX; #define RGB(r,g,b) (PIX) ( ((b) >> 3) | (((g) >> 2) << 5) | \ (((r) >> 3) << 11) ) /* 565, low byte first assumed! */ /* To find the screen size and color depth: */ XGetGeometry( Display* display, Drawable d, Window* root_return, int* x_return, int* y_return, unsigned int* width_return, unsigned int* height_return, unsigned int* border_width_return, unsigned int* depth_return ); XCreateSimpleWindow( Display* display, Window parent, int x, int y, unsigned int width, unsigned int height, unsigned int border_width, unsigned long border, unsigned long background ); Display* dis = XOpenDisplay ( NULL ); if ( dis != NULL ) { disScreen = DefaultScreen ( dis ); disDepth = DefaultDepth ( dis , disScreen ); disWidth = DisplayWidth ( dis , disScreen ); disHeight = DisplayHeight ( dis , disScreen ); } Window winRoot = DefaultRootWindow ( dis ); Window myWindow = XCreateSimpleWindow( ... ); XStoreName ( dis , win , "Name of your window" ); XClearWindow ( dis , win ); XMapRaised ( dis , win ); XFlush ( dis ); /* you can use XCreateImage() to control a bitmap in the window... */ XGCValues gcVal; gcVal.foreground = 0; gcVal.background = 0; unsigned long gcMask = GCForeground | GCBackground; GC gc = XCreateGC ( dis , win , gcMask , &gcVal ); /* *** YOUR CODE HERE *** */ /* *** to update the display, use XPutImage() if you have *** */ /* *** changed the bitmap. Other drawing takes effect at *** */ /* *** once but you can use XFlush(Display* display) or *** */ /* *** wait using XSync(Display* display, Bool discard). *** */ /* *** (discard should be false...) *** */ XFreeGC ( dis , gc ); /* XDestroyImage ( xim ); */ XDestroyWindow ( dis , win ); XCloseDisplay ( dis ); /* *** HAVE SOME DRAWING PRIMITIVES... HAVE FUN! *** */ XDrawLine( Display* display, Drawable d, GC gc, int x1, int x1, int y1, int y2 ); /* mode is either of CoordModeOrigin or CoordModePrevious */ XDrawLines( Display* display, Drawable d, GC gc, XPoint* points, int npoints, int mode ); XDrawRectangle( Display* display, Drawable d, GC gc, int x, int y, unsigned int width, unsigned int height ); XDrawArc( Display* display, Drawable d, GC gc, int x, int y, unsigned int width, unsigned int height, int angle1, int angle2 ); /* see also XSetFont(); XDrawString( Display* display, Drawable d, GC gc, int x, int y, _Xconst char* string, int length ); XFillRectangle( Display* display, Drawable d, GC gc, int x, int y, unsigned int width, unsigned int height ); XDrawPoint( Display* display, Drawable d, GC gc, int x, int y ); XFillRectangle( Display* display, Drawable d, GC gc, int x, int y, unsigned int width, unsigned int height ); XFillArc( Display* display, Drawable d, GC gc, int x, int y, unsigned int width, unsigned int height, int angle1, int angle2 ); /* shape is either of Complex, Convex or Nonconvex. Use */ /* complex if you are not sure and need no optimization. */ /* mode is either of CoordModeOrigin or CoordModePrevious */ XFillPolygon( Display* display, Drawable d, GC gc, XPoint* points, int npoints, int shape, int mode ); /* fill_style is either of FillSolid, FillTiles, FillStippled */ /* or FillOpaqueStippled... */ /* see also XSetStipple() XSetTile() XSetDashes() for lines */ XSetFillStyle( Display* display, GC gc, int fill_style ); XSetForeground( Display* display, GC gc, unsigned long foreground ); /* arc_mode is either of ArcChord, ArcPieSlice */ XSetArcMode( Display* display, GC gc, int arc_mode ); /* line_style is either of LineSolid, LineOnOffDash, */ /* LineDoubleDash. cap_style is either of CapNotLast, */ /* CapButt, CapRound, CapProjecting. join_style is */ /* either of JoinMiter, JoinRound, JoinBevel. */ XSetLineAttributes( Display* display, GC gc, unsigned int line_width, int line_style, int cap_style, int join_style );