home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / ober1096.zip / libsrc / Xlib.def < prev    next >
Text File  |  1995-04-04  |  12KB  |  388 lines

  1. INTERFACE DEFINITION MODULE Xlib;
  2.  
  3. (* Modula definition of Xlib library facilities defined in Xlib.h
  4.  
  5.    Revision record:
  6.  
  7.       Nov 89  John Hynd  Original minimal version
  8.    19 Sep 90  John Hynd  Add GC display functions
  9. *)
  10.  
  11. IMPORT IMPLEMENTATION FROM "-lX11";
  12.  
  13. FROM Xglobal IMPORT int, long, unsigned, unsignedInt, unsignedLong,
  14.     unsignedShort, Bool;
  15. FROM SYSTEM IMPORT BYTE, ADDRESS;
  16.  
  17.  
  18. CONST
  19.   AllocNone = 0;
  20.   AllocAll = 1;
  21.   Fail = 0;
  22.   Success = 1;        (* Good Status - Xlib.h says 0!? *)
  23.  
  24.   None = 0;
  25.   many = 100; (* for pointers to 'open' arrays *)
  26.  
  27.   (* Input event masks *)
  28.   ExposureMask      = 8000H;
  29.   PointerMotionMask = 0040H;
  30.   ButtonPressMask   = 0004H;
  31.   KeyPressMask      = 0001H;
  32.  
  33.   (* Event names *)
  34.   KeyPress = 2;
  35.   ButtonPress = 4;
  36.   MotionNotify = 6;
  37.   Expose = 12;
  38.  
  39.   (* Visual attribute masks *)
  40.   VisualNoMask     = 0000H;
  41.   VisualIDMask     = 0001H;
  42.   VisualScreenMask = 0002H;
  43.   VisualDepthMask  = 0004H;
  44.   (* ... *)
  45.   VisualAllMask    = 01FFH;
  46.  
  47.   QueuedAlready        = 0;
  48.   QueuedAfterReading    = 1;
  49.   QueuedAfterFlush    = 2;
  50.  
  51.   (* Point draw modes *)
  52.   CoordModeOrigin   = 0;    (* relative to origin - absolute! *)
  53.   CoordModePrevious = 1;    (* relative to previous point
  54.                    - first is absolute *)
  55.  
  56.   (* Polygon fill shapes *)
  57.   Complex = 0;            (* paths may intersect *)
  58.   Nonconvex = 1;        (* no paths intersect, but not convex *)
  59.   Convex = 2;            (* wholly convex *)
  60.  
  61.   (* GC display functions *)
  62.   GXclear = 0;
  63.   (* ... *)
  64.   GXcopy = 3;
  65.   (* ... *)
  66.   GXxor = 6;
  67.   (* ... *)
  68.   GXset = 15;
  69.  
  70. TYPE
  71.   Status = int;
  72.  
  73.   XID = unsignedLong;
  74.  
  75.   Undefined = INTEGER;
  76.   XComposeStatus = Undefined;
  77.  
  78.   Display = BYTE;
  79.   DisplayPtr = POINTER TO Display;
  80.   Window = XID;
  81.  
  82.   GC = POINTER TO BYTE;
  83.   XGCValuesPtr = POINTER TO BYTE;
  84.   Drawable = XID;
  85.   Font = XID;
  86.  
  87.   KeySym = XID;
  88.  
  89.   Time = unsignedLong;
  90.  
  91.   (* Event descriptors *)
  92.   XKeyEvent = RECORD
  93.     type : int;
  94.     serial : unsignedLong;
  95.     sendEvent : Bool;
  96.     display : DisplayPtr;
  97.     window,
  98.     root,
  99.     subwindow : Window;
  100.     time : Time;
  101.     x, y : int;
  102.     xRoot, yRoot : int;
  103.     state,
  104.     keycode: unsignedInt;
  105.     sameScreen : Bool;
  106.       END;
  107.   XButtonEvent = RECORD
  108.     type : int;
  109.     serial : unsignedLong;
  110.     sendEvent : Bool;
  111.     display : DisplayPtr;
  112.     window,
  113.     root,
  114.     subwindow : Window;
  115.     time : Time;
  116.     x, y : int;
  117.     xRoot, yRoot : int;
  118.     state,
  119.     button: unsignedInt;
  120.     sameScreen : Bool;
  121.       END;
  122.   XExposeEvent = RECORD
  123.     type : int;
  124.     serial : unsignedLong;
  125.     sendEvent : Bool;
  126.     display : DisplayPtr;
  127.     window : Window;
  128.     x, y : int;
  129.     width, height : int;
  130.     count : int;
  131.       END;
  132.   XEvent = RECORD CASE : CARDINAL OF (* C union *)
  133.     |  0 : type : int;
  134.     |  2 : xkey : XKeyEvent;
  135.     |  3 : xbutton : XButtonEvent;
  136.     |  7 : xexpose : XExposeEvent;
  137.     | 32 : pad : ARRAY [0..23] OF long;
  138.     END;
  139.       END;
  140.  
  141.   VisualPtr = POINTER TO VisualInfo;
  142.   VisualID = unsignedLong;    (* XID! *)
  143.   VisualInfo = RECORD
  144.     visual : VisualPtr;
  145.     visualid : VisualID;
  146.     screen : int;
  147.     depth : unsignedInt;
  148.     class : int;
  149.     redMask, greenMask, blueMask : unsignedLong;
  150.     colormapSize : int;
  151.     bitsPerRGB : int;
  152.       END;
  153.   VisualInfoPtr = POINTER TO ARRAY [0..many] OF VisualInfo;
  154.   Colormap = XID;
  155.   XColor = RECORD
  156.     pixel : unsignedLong;
  157.     red, green, blue : unsignedShort;
  158.     flags : CHAR;
  159.     pad : CHAR;
  160.       END;
  161.  
  162.   XPoint = RECORD
  163.          x, y : int;
  164.        END;
  165.  
  166. PROCEDURE XAllocColorCells (display : DisplayPtr;
  167.                 colorMap : Colormap;
  168.                 contig : BOOLEAN;
  169.                 VAR planemaskreturn : ARRAY OF long;
  170.                 nplanes : INTEGER;
  171.                 VAR pixelsreturn : ARRAY OF long;
  172.                 npixels : INTEGER) : Status;
  173. (* See man 3 XAllocColorCells *)
  174.  
  175. PROCEDURE XAllocColor (display : DisplayPtr; colorMap : Colormap;
  176.     VAR screenInOut : XColor)
  177.     : Status;
  178. (* Allocate by RGB value a read-only colour cell for the screen associated
  179.    with the given colourmap, and return the closest colour supported by the
  180.    screen. *)
  181.  
  182. PROCEDURE XAllocNamedColor (display : DisplayPtr; colorMap : Colormap;
  183.     colourName : ARRAY OF CHAR; VAR screenDef, exactDef : XColor)
  184.     : Status;
  185. (* Allocate by name a read-only colour cell for the screen associated with the
  186.    given colourmap, and return the exact database definition and the
  187.    closest colour supported by the screen. *)
  188.  
  189. PROCEDURE XOpenDisplay(displayName : ARRAY OF CHAR) : DisplayPtr;
  190. (* Connect a client program to an X server *)
  191.  
  192. PROCEDURE XDefaultScreen(display : DisplayPtr) : int;
  193.  
  194. PROCEDURE XWhitePixel(display : DisplayPtr; screen : int) : unsignedLong;
  195.  
  196. PROCEDURE XBlackPixel(display : DisplayPtr; screen : int) : unsignedLong;
  197.  
  198. PROCEDURE XDisplayWidth(display : DisplayPtr; screen : int) : int;
  199.  
  200. PROCEDURE XDisplayHeight(display : DisplayPtr; screen : int) : int;
  201.  
  202. PROCEDURE XCreateSimpleWindow(display : DisplayPtr; parent : Window;
  203.        x, y : int; width, height, borderWidth : unsigned;
  204.        border, background : unsignedLong) : Window;
  205. (* Create an unmapped InputOutput window *)
  206.  
  207. PROCEDURE XDefaultRootWindow(display : DisplayPtr) : Window;
  208.  
  209. PROCEDURE XStoreName(display : DisplayPtr; window : Window;
  210.              name : ARRAY OF CHAR);
  211. (* Give the window manager a hint for the window name *)
  212.  
  213. PROCEDURE XCreateGC(display : DisplayPtr; drawable : Drawable;
  214.             valueMask : unsignedLong; values : XGCValuesPtr) : GC;
  215. (* Create a new graphics context for a given screen with the depth of the
  216.    specified drawable.
  217.    The values parameter is a pointer so that NIL may be passed. *)
  218.  
  219. PROCEDURE XCreateColormap (display : DisplayPtr;
  220.                 window : Window;
  221.                 visual : VisualPtr;
  222.                 alloc : INTEGER) : Colormap;
  223. (* alloc is AllocAll or AllocNone *)
  224.  
  225. PROCEDURE XLoadFont(display : DisplayPtr; name : ARRAY OF CHAR) : Font;
  226. (* Load a font if not already loaded; get font ID *)
  227.  
  228. PROCEDURE XSetForeground (display : DisplayPtr; gc : GC ;
  229.               foreground : unsignedLong);
  230. (* Set the foreground pixel in a graphics context *)
  231.  
  232. PROCEDURE XSetFunction (display : DisplayPtr; gc : GC ; function : int);
  233. (* Set the display function in a graphics context *)
  234.  
  235. PROCEDURE XSetFont (display : DisplayPtr; gc : GC ; font : Font);
  236. (* Set the current font in a graphics context *)
  237.  
  238. PROCEDURE XSelectInput (display : DisplayPtr; w : Window;
  239.     eventMask : long);
  240. (* Select events to be reported to client *)
  241.  
  242. PROCEDURE XNextEvent (display : DisplayPtr; VAR eventReturn : XEvent);
  243. (* Get the next event and remove it from the queue *)
  244.  
  245. PROCEDURE XEventsQueued (display : DisplayPtr; mode : int) : int;
  246. (* Return the number of events queued, by mode:
  247.      QueuedAlready, QueuedAfterFlush or QueuedAfterReading *)
  248.  
  249. PROCEDURE XPending (display : DisplayPtr) : int;
  250. (* Return the number of pending requests (same as XEventsQueued
  251.     with the QueuedAfterFlush mode) *)
  252.  
  253. PROCEDURE XCheckTypedEvent (display : DisplayPtr; eventType : int;
  254.                 VAR eventReturn : XEvent) : BOOLEAN;
  255. (* Get the next event of the specified type and remove it from the queue *)
  256.  
  257. PROCEDURE XMapRaised (display : DisplayPtr; w : Window);
  258. (* Map a window on top of its siblings *)
  259.  
  260. PROCEDURE XMapWindow (display : DisplayPtr; w : Window);
  261. (* Map a window on top? of its siblings *)
  262.  
  263. PROCEDURE XClearWindow (display : DisplayPtr; w : Window);
  264. (* Clears the window *)
  265.  
  266. PROCEDURE XDrawPoint (display : DisplayPtr; d : Drawable; gc : GC;
  267.     x, y : int);
  268. (* Draw a point at (x,y) on the drawable d with graphics context gc *)
  269.  
  270. PROCEDURE XDrawPoints (display : DisplayPtr; d : Drawable; gc : GC;
  271.     VAR points : ARRAY OF XPoint; nPoints,  mode : int);
  272. (* Draw a point at (x,y) on the drawable d with graphics context gc *)
  273.  
  274. PROCEDURE XDrawLine (display : DisplayPtr; d : Drawable; gc : GC;
  275.     x1, y1, x2, y2 : int);
  276. (* Draw a line from (x1,y1) to (x2,y2) on the drawable d with graphics
  277.    context gc *)
  278.  
  279. PROCEDURE XDrawLines (display : DisplayPtr; d : Drawable; gc : GC;
  280.     VAR points : ARRAY OF XPoint; nPoints, mode : int);
  281. (* Draw (nPoints-1) connected lines (i.e., a polyline) on the drawable d
  282.    with graphics context gc. Endpoints are joined correctly. *)
  283.  
  284. (* To come : XDrawSegments *)
  285.  
  286. PROCEDURE XDrawRectangle (display : DisplayPtr; d : Drawable; gc : GC;
  287.     x, y : INTEGER; width, height : unsigned);
  288. (* Draw a rectangle with upper left corner (x,y), and given width and
  289.    height on drawable d *)
  290.  
  291. (* To come : XDrawRectangles *)
  292.  
  293. PROCEDURE XDrawArc (display : DisplayPtr; d : Drawable; gc : GC;
  294.     x, y : int; width, height : unsignedInt; angle1, angle2 : int);
  295. (* Draw a circular or elliptical arc with bounding rectangle top left at (x,y),
  296.    width and height, from angle1 to angle2 (positive counterclockwise,
  297.    limited to 360 degrees). *)
  298.  
  299. (* To come : XDrawArcs *)
  300.  
  301. PROCEDURE XFillRectangle (display : DisplayPtr; d : Drawable; gc : GC;
  302.     x, y : INTEGER; width, height : unsigned);
  303. (* Draw a filled rectangle with upper left corner (x,y), and given width and
  304.    height on drawable d *)
  305.  
  306. (* To come : XFillRectangles *)
  307.  
  308. PROCEDURE XFillPolygon (display : DisplayPtr; d : Drawable; gc : GC;
  309.     VAR points : ARRAY OF XPoint; nPoints, shape, mode : int);
  310. (* Fill the region closed by the specified path (closed if necessary).
  311.    Shape specifies convexity; mode is absolute / relative. *)
  312.  
  313. PROCEDURE XFillArc (display : DisplayPtr; d : Drawable; gc : GC;
  314.     x, y : int; width, height : unsignedInt; angle1, angle2 : int);
  315. (* Fill a circular or elliptical arc with bounding rectangle top left at (x,y),
  316.    width and height, from angle1 to angle2 (positive counterclockwise,
  317.    limited to 360 degrees). *)
  318.  
  319. (* To come : XFillArcs *)
  320.  
  321. PROCEDURE XDrawString (display : DisplayPtr; d : Drawable; gc : GC;
  322.     x, y : int; string : ARRAY OF CHAR; length : int);
  323. (* Draw a string at (x,y) on drawable d, foreground only *)
  324.  
  325. PROCEDURE XDrawImageString (display : DisplayPtr; d : Drawable; gc : GC;
  326.     x, y : int; string : ARRAY OF CHAR; length : int);
  327. (* Draw an image string at (x,y) on drawable d *)
  328.  
  329. PROCEDURE XDefaultGC(display : DisplayPtr; screenNumber : INTEGER) : GC;
  330. (* Return the default graphics context *)
  331.  
  332. PROCEDURE XWarpPointer (display : DisplayPtr; srcW, dstW : Window;
  333.     srcX, srcY : int; srcWidth, srcHeight : unsignedInt;
  334.     destX, destY : int);
  335. (* Move the pointer suddenly to another point on the screen *)
  336.  
  337. PROCEDURE XLookupString(VAR event : XEvent; buffer : ARRAY OF CHAR;
  338.     numBytes : int; VAR keysym : KeySym; status : XComposeStatus) : int;
  339. (* Map a key event to an ASCII string, keysym and ComposeStatus;
  340.    return length of trnaslated string *)
  341.  
  342. PROCEDURE XQueryPointer(display : DisplayPtr; w : Window;
  343.     VAR root, child : Window; VAR rootX, rootY, winX, winY : int;
  344.     VAR buttons : unsignedInt) : Bool;
  345. (* Get the current pointer location *)
  346.  
  347. PROCEDURE XDisplayPlanes (display : DisplayPtr; screen : int) : int;
  348. (* Return the depth of the root window *)
  349.  
  350. PROCEDURE XDefaultVisual (display : DisplayPtr; screen : int) : VisualPtr;
  351. (* Return the default visual type of the screen *)
  352.  
  353. PROCEDURE XGetVisualInfo (display : DisplayPtr; vinfoMask : long;
  354.     VAR vinfoTemplate : VisualInfo; VAR nitemsReturn : int) : VisualInfoPtr;
  355. (* Return a list of visuals which match the attributes in the template
  356.    selected by the mask. *)
  357.  
  358. PROCEDURE XFree (data : ADDRESS);
  359. (* Free in-memory data created by some X function. *)
  360.  
  361. PROCEDURE XDefaultColormap (display : DisplayPtr; screen : int) : Colormap;
  362. (* Return the default colour map for allocation on the screen *)
  363.  
  364. PROCEDURE XStoreColor (display : DisplayPtr;
  365.             colormap : Colormap;
  366.             color : XColor);
  367. (* Sets the pixel colour as defined in the XColor record *)
  368.  
  369. PROCEDURE XCopyColormapAndFree (display : DisplayPtr;
  370.                 colormap : Colormap) : Colormap;
  371. (* copies the colour map *)
  372.  
  373. PROCEDURE XInstallColormap (display : DisplayPtr; colormap : Colormap);
  374.  
  375. PROCEDURE XQueryColor (display : DisplayPtr; colourmap : Colormap;
  376.     VAR colour : XColor);
  377. (* Get the RGB values for colour.pixel. *)
  378.  
  379. PROCEDURE XFlush (display : DisplayPtr);
  380. (* Flush the output buffer (display all queued requests) *)
  381.  
  382. PROCEDURE XDestroyWindow (display : DisplayPtr; w : Window);
  383. (* Destroy w and all its subwindows *)
  384.  
  385. PROCEDURE XCloseDisplay (display : DisplayPtr);
  386. (* Close connection to X server, destroying all windows, resources, etc *)
  387. END Xlib.
  388.