% Copyright Barbara Liskov 1985, 1986 x_window = cluster is none, create, create_transparency, destroy, destroy_subwindows, map, map_subwindows, unmap, unmap_subwindows, unmap_transparent, raise, lower, circulate_up, circulate_down, move, change, configure, set_background, set_border, set_tilemode, set_clipmode, query, query_tree, get_name, set_name, set_icon, get_resize, set_resize, set_cursor, set_input, grab_mouse, ungrab_mouse, grab_button, ungrab_button, query_mouse, interpret_locator, warp_mouse, cond_warp_mouse, focus_keyboard, clear, pix_set, pix_fill, tile_set, tile_fill, pixmap_put, pixmap_xybitsput, pixmap_zbitsput, bitmap_bitsput, move_area, copy_area, text, textv, texta, text_pad, textv_pad, texta_pad, text_mask, textv_mask, texta_mask, text_mask_pad, textv_mask_pad, texta_mask_pad, line, draw, draw_dashed, draw_patterned, draw_filled, draw_tiled, save_region, read_xyregion, read_zregion, get_id, equal, similar, copy rep = int none = proc () returns (cvt) return(0) end none create = proc (x, y, width, height: int, background: x_pixmap, parent: cvt, borderwidth: int, border: x_pixmap) returns (cvt) signals (error(string)) x_buf$setup(x_createwindow, borderwidth, 0, parent) x_buf$set_s0123(height, width, x, y) x_buf$set_l23(border.id, background.id) x_buf$receive() resignal error return(x_buf$get_lp0()) end create create_transparency = proc (x, y, width, height: int, parent: cvt) returns (cvt) signals (error(string)) x_buf$setup(x_createtransparency, 0, 0, parent) x_buf$set_s0123(height, width, x, y) x_buf$receive() resignal error return(x_buf$get_lp0()) end create_transparency destroy = proc (w: cvt) x_buf$setup(x_destroywindow, 0, 0, w) end destroy destroy_subwindows = proc (w: cvt) x_buf$setup(x_destroysubwindows, 0, 0, w) end destroy_subwindows map = proc (w: cvt) x_buf$setup(x_mapwindow, 0, 0, w) end map map_subwindows = proc (w: cvt) x_buf$setup(x_mapsubwindows, 0, 0, w) end map_subwindows unmap = proc (w: cvt) x_buf$setup(x_unmapwindow, 0, 0, w) end unmap unmap_subwindows = proc (w: cvt) x_buf$setup(x_unmapsubwindows, 0, 0, w) end unmap_subwindows unmap_transparent = proc (w: cvt) x_buf$setup(x_unmaptransparent, 0, 0, w) end unmap_transparent raise = proc (w: cvt) x_buf$setup(x_raisewindow, 0, 0, w) end raise lower = proc (w: cvt) x_buf$setup(x_lowerwindow, 0, 0, w) end lower circulate_up = proc (w: cvt) x_buf$setup(x_circwindowup, 0, 0, w) end circulate_up circulate_down = proc (w: cvt) x_buf$setup(x_circwindowdown, 0, 0, w) end circulate_down move = proc (w: cvt, x, y: int) x_buf$setup(x_movewindow, 0, 0, w) x_buf$set_s01(x, y) end move change = proc (w: cvt, width, height: int) x_buf$setup(x_changewindow, 0, 0, w) x_buf$set_s01(height, width) end change configure = proc (w: cvt, x, y, width, height: int) x_buf$setup(x_configurewindow, 0, 0, w) x_buf$set_s0123(height, width, x, y) end configure set_background = proc (w: cvt, background: x_pixmap) x_buf$setup(x_changebackground, 0, 0, w) x_buf$set_l0(p2i(background)) end set_background set_border = proc (w: cvt, border: x_pixmap) x_buf$setup(x_changeborder, 0, 0, w) x_buf$set_l0(p2i(border)) end set_border set_tilemode = proc (w: cvt, relative: bool) if relative then x_buf$setup(x_tilemode, TileModeRelative, 0, w) else x_buf$setup(x_tilemode, TileModeAbsolute, 0, w) end end set_tilemode set_clipmode = proc (w: cvt, drawthru: bool) if drawthru then x_buf$setup(x_clipmode, ClipModeDrawThru, 0, w) else x_buf$setup(x_clipmode, ClipModeClipped, 0, w) end end set_clipmode % returns (x, y, width, height, border, map, kind, icon) query = proc (w: cvt) returns (int, int, int, int, int, int, int, cvt) signals (error(string)) x_buf$setup(x_querywindow, 0, 0, w) x_buf$receive() resignal error return(x_buf$get_sp2(), x_buf$get_sp3(), x_buf$get_sp1(), x_buf$get_sp0(), x_buf$get_sp4(), x_buf$get_bp10(), x_buf$get_bp11(), x_buf$get_lp3()) end query query_tree = proc (w: cvt) returns (cvt, wlist) signals (error(string)) wlist = array[x_window] x_buf$setup(x_querytree, 0, 0, w) x_buf$receive() resignal error parent: int := x_buf$get_lp0() n: int := x_buf$get_lp1() subs: wlist := wlist$fill(1, n, up(parent)) if n > 0 then b: _bytevec := _bytevec$create(n * 4) x_buf$receive_data(b) for i: int in int$from_to(1, n) do subs[i] := up(b2w(b)[i]) end end return(parent, subs) end query_tree get_name = proc (w: cvt) returns (string) signals (error(string)) x_buf$setup(x_fetchname, 0, 0, w) x_buf$receive() resignal error n: int := x_buf$get_sp0() if n = 0 then return("") end b: _bytevec := _bytevec$create(n) x_buf$receive_data(b) return(b2s(b)) end get_name set_name = proc (w: cvt, n: string) x_buf$setup(x_storename, 0, 0, w) x_buf$set_s0(string$size(n)) x_buf$send_data(s2b(n), 1, string$size(n)) end set_name set_icon = proc (w, icon: cvt) x_buf$setup(x_seticonwindow, 0, 0, w) x_buf$set_l0(icon) end set_icon get_resize = proc (w: cvt) returns (int, int, int, int) signals (error(string)) x_buf$setup(x_getresizehint, 0, 0, w) x_buf$receive() resignal error return(x_buf$get_sp2(), x_buf$get_sp3(), x_buf$get_sp0(), x_buf$get_sp1()) end get_resize set_resize = proc (w: cvt, width0, widthinc, height0, heightinc: int) x_buf$setup(x_setresizehint, 0, 0, w) x_buf$set_s0123(height0, heightinc, width0, widthinc) end set_resize set_cursor = proc (w: cvt, cursor: x_cursor) x_buf$setup(x_definecursor, 0, 0, w) x_buf$set_l0(c2i(cursor)) end set_cursor set_input = proc (w: cvt, mask: int) x_buf$setup(x_selectinput, 0, 0, w) x_buf$set_l0(mask) end set_input grab_mouse = proc (w: cvt, mask: int, cursor: x_cursor) signals (error(string)) x_buf$setup(x_grabmouse, 0, 0, w) x_buf$set_l01(c2i(cursor), mask) x_buf$receive() resignal error end grab_mouse ungrab_mouse = proc () x_buf$setup(x_ungrabmouse, 0, 0, 0) end ungrab_mouse grab_button = proc (w: cvt, button, mask: int, cursor: x_cursor) signals (error(string)) x_buf$setup(x_grabbutton, 0, button, w) x_buf$set_l01(c2i(cursor), mask) x_buf$receive() resignal error end grab_button ungrab_button = proc (button: int) x_buf$setup(x_ungrabmouse, 0, button, 0) end ungrab_button % returns (x, y, window) query_mouse = proc (w: cvt) returns (int, int, cvt) signals (error(string)) x_buf$setup(x_querymouse, 0, 0, w) x_buf$receive() resignal error return(x_buf$get_sp2(), x_buf$get_sp3(), x_buf$get_lp0()) end query_mouse interpret_locator = proc (w: cvt, x, y: int) returns (int, int, cvt) signals (error(string)) x_buf$setup(x_interpretlocator, 0, 0, w) x_buf$set_s01(x, y) x_buf$receive() resignal error return(x_buf$get_sp2(), x_buf$get_sp3(), x_buf$get_lp0()) end interpret_locator warp_mouse = proc (w: cvt, x, y: int) x_buf$setup(x_warpmouse, 0, 0, w) x_buf$set_s01l1(x, y, down(x_display$root())) x_buf$set_s4567(0, 0, 0, 0) end warp_mouse cond_warp_mouse = proc (dstw: cvt, dstx, dsty: int, srcw: cvt, srcx, srcy, srcwidth, srcheight: int) x_buf$setup(x_warpmouse, 0, 0, dstw) x_buf$set_s01l1(dstx, dsty, srcw) x_buf$set_s4567(srcheight, srcwidth, srcx, srcy) end cond_warp_mouse focus_keyboard = proc (w: cvt) x_buf$setup(x_focuskeyboard, 0, 0, w) end focus_keyboard clear = proc (w: cvt) x_buf$setup(x_clear, 0, 0, w) end clear pix_set = proc (w: cvt, pixel, x, y, width, height: int) x_buf$setup(x_pixfill, GXcopy, -1, w) x_buf$set_s0123(height, width, x, y) x_buf$set_s45l3(pixel, 0, 0) end pix_set pix_fill = proc (w: cvt, pixel: int, mask: x_bitmap, x, y, width, height: int, func, planes: int) x_buf$setup(x_pixfill, func, planes, w) x_buf$set_s0123(height, width, x, y) x_buf$set_s45l3(pixel, 0, b2i(mask)) end pix_fill tile_set = proc (w: cvt, tile: x_pixmap, x, y, width, height: int) x_buf$setup(x_tilefill, GXcopy, -1, w) x_buf$set_s0123(height, width, x, y) x_buf$set_l23(p2i(tile), 0) end tile_set tile_fill = proc (w: cvt, tile: x_pixmap, mask: x_bitmap, x, y, width, height, func, planes: int) x_buf$setup(x_tilefill, func, planes, w) x_buf$set_s0123(height, width, x, y) x_buf$set_l23(p2i(tile), b2i(mask)) end tile_fill pixmap_put = proc (w: cvt, pix: x_pixmap, srcx, srcy, width, height, dstx, dsty, func, planes: int) x_buf$setup(x_pixmapput, func, planes, w) x_buf$set_s0123(height, width, srcx, srcy) x_buf$set_l2s67(p2i(pix), dstx, dsty) end pixmap_put pixmap_zbitsput = proc (w: cvt, width, height: int, bits: _wordvec, mask: x_bitmap, x, y, func, planes: int) x_buf$setup(x_pixmapbitsput, func, planes, w) x_buf$set_s0123(height, width, x, y) x_buf$set_s45l3(ZFormat, 0, b2i(mask)) z: int := width * height if x_display$planes() > 8 then z := z + z end x_buf$send_data(w2b(bits), 1, z) end pixmap_zbitsput pixmap_xybitsput = proc (w: cvt, width, height: int, bits: _wordvec, mask: x_bitmap, x, y, func, planes: int) x_buf$setup(x_pixmapbitsput, func, planes, w) x_buf$set_s0123(height, width, x, y) x_buf$set_s45l3(XYFormat, 0, b2i(mask)) x_buf$send_data(w2b(bits), 1, ((width + 15) / 16) * height * 2 * x_display$planes()) end pixmap_xybitsput bitmap_bitsput = proc (w: cvt, width, height: int, bits: _wordvec, fore, back: int, mask: x_bitmap, x, y, func, planes: int) x_buf$setup(x_bitmapbitsput, func, planes, w) x_buf$set_s0123(height, width, x, y) x_buf$set_s45l3(fore, back, b2i(mask)) x_buf$send_data(w2b(bits), 1, ((width + 15) / 16) * height * 2) end bitmap_bitsput move_area = proc (w: cvt, srcx, srcy, width, height, dstx, dsty: int) x_buf$setup(x_copyarea, GXcopy, -1, w) x_buf$set_s0123(height, width, srcx, srcy) x_buf$set_s4567(0, 0, dstx, dsty) end move_area copy_area = proc (w: cvt, srcx, srcy, width, height, dstx, dsty: int, func, planes: int) x_buf$setup(x_copyarea, func, planes, w) x_buf$set_s0123(height, width, srcx, srcy) x_buf$set_s4567(0, 0, dstx, dsty) end copy_area text = proc (w: cvt, s: string, font: x_font, fore, back, x, y: int) x_buf$setup(x_text, GXcopy, -1, w) x_buf$set_s01l1(x, y, f2i(font)) x_buf$set_s4567(fore, back, string$size(s), 0) x_buf$send_data(s2b(s), 1, string$size(s)) end text textv = proc (w: cvt, b: _bytevec, start, z: int, font: x_font, fore, back, x, y: int) x_buf$setup(x_text, GXcopy, -1, w) x_buf$set_s01l1(x, y, f2i(font)) x_buf$set_s4567(fore, back, z, 0) x_buf$send_data(b, start, z) end textv texta = proc (w: cvt, a: array[char], start, z: int, font: x_font, fore, back, x, y: int) x_buf$setup(x_text, GXcopy, -1, w) x_buf$set_s01l1(x, y, f2i(font)) x_buf$set_s4567(fore, back, z, 0) x_buf$send_array(a, start, z) end texta text_pad = proc (w: cvt, s: string, font: x_font, fore, back, cpad, spad: int, x, y: int, func, planes: int) x_buf$setup(x_text, func, planes, w) x_buf$set_s01l1(x, y, f2i(font)) x_buf$set_s4567(fore, back, string$size(s), (spad // 2**8) + cpad * 2**8) x_buf$send_data(s2b(s), 1, string$size(s)) end text_pad textv_pad = proc (w: cvt, b: _bytevec, start, z: int, font: x_font, fore, back, cpad, spad: int, x, y: int, func, planes: int) x_buf$setup(x_text, func, planes, w) x_buf$set_s01l1(x, y, f2i(font)) x_buf$set_s4567(fore, back, z, (spad // 2**8) + cpad * 2**8) x_buf$send_data(b, start, z) end textv_pad texta_pad = proc (w: cvt, a: array[char], start, z: int, font: x_font, fore, back, cpad, spad: int, x, y: int, func, planes: int) x_buf$setup(x_text, func, planes, w) x_buf$set_s01l1(x, y, f2i(font)) x_buf$set_s4567(fore, back, z, (spad // 2**8) + cpad * 2**8) x_buf$send_array(a, start, z) end texta_pad text_mask = proc (w: cvt, s: string, font: x_font, pixel, x, y: int) x_buf$setup(x_textmask, GXcopy, -1, w) x_buf$set_s01l1(x, y, f2i(font)) x_buf$set_s4567(pixel, 0, string$size(s), 0) x_buf$send_data(s2b(s), 1, string$size(s)) end text_mask textv_mask = proc (w: cvt, b: _bytevec, start, z: int, font: x_font, pixel, x, y: int) x_buf$setup(x_textmask, GXcopy, -1, w) x_buf$set_s01l1(x, y, f2i(font)) x_buf$set_s4567(pixel, 0, z, 0) x_buf$send_data(b, start, z) end textv_mask texta_mask = proc (w: cvt, a: array[char], start, z: int, font: x_font, pixel, x, y: int) x_buf$setup(x_textmask, GXcopy, -1, w) x_buf$set_s01l1(x, y, f2i(font)) x_buf$set_s4567(pixel, 0, z, 0) x_buf$send_array(a, start, z) end texta_mask text_mask_pad = proc (w: cvt, s: string, font: x_font, pixel, cpad, spad: int, x, y: int, func, planes: int) x_buf$setup(x_textmask, func, planes, w) x_buf$set_s01l1(x, y, f2i(font)) x_buf$set_s4567(pixel, 0, string$size(s), (spad // 2**8) + cpad * 2**8) x_buf$send_data(s2b(s), 1, string$size(s)) end text_mask_pad textv_mask_pad = proc (w: cvt, b: _bytevec, start, z: int, font: x_font, pixel, cpad, spad: int, x, y: int, func, planes: int) x_buf$setup(x_textmask, func, planes, w) x_buf$set_s01l1(x, y, f2i(font)) x_buf$set_s4567(pixel, 0, z, (spad // 2**8) + cpad * 2**8) x_buf$send_data(b, start, z) end textv_mask_pad texta_mask_pad = proc (w: cvt, a: array[char], start, z: int, font: x_font, pixel, cpad, spad: int, x, y: int, func, planes: int) x_buf$setup(x_textmask, func, planes, w) x_buf$set_s01l1(x, y, f2i(font)) x_buf$set_s4567(pixel, 0, z, (spad // 2**8) + cpad * 2**8) x_buf$send_array(a, start, z) end texta_mask_pad line = proc (w: cvt, pixel, width, height, x1, y1, x2, y2, func, planes: int) x_buf$setup(x_line, func, planes, w) x_buf$set_s0123(x1, y1, x2, y2) x_buf$set_s4567(pixel, (width // 2**8) + height * 2**8, 0, 0) end line draw = proc (w: cvt, verts: x_vlist, z, pixel, width, height, func, planes: int) x_buf$setup(x_draw, func, planes, w) x_buf$set_s0123(z, pixel, (width // 2**8) + height * 2**8, DrawSolidLine) x_buf$send_data(v2b(verts), 1, 6 * z) end draw draw_dashed = proc (w: cvt, verts: x_vlist, z, pixel, width, height: int, pattern, patlen, patmul, func, planes: int) x_buf$setup(x_draw, func, planes, w) x_buf$set_s0123(z, pixel, (width // 2**8) + height * 2**8, DrawDashedLine) x_buf$set_s4567(0, pattern, patlen, patmul) x_buf$send_data(v2b(verts), 1, 6 * z) end draw_dashed draw_patterned = proc (w: cvt, verts: x_vlist, z, pixel, altpix: int, width, height, pattern, patlen, patmul, func, planes: int) x_buf$setup(x_draw, func, planes, w) x_buf$set_s0123(z, pixel, (width // 2**8) + height * 2**8, DrawPatternedLine) x_buf$set_s4567(altpix, pattern, patlen, patmul) x_buf$send_data(v2b(verts), 1, 6 * z) end draw_patterned draw_filled = proc (w: cvt, verts: x_vlist, z, pixel, func, planes: int) x_buf$setup(x_drawfilled, func, planes, w) x_buf$set_s01l1(z, pixel, 0) x_buf$send_data(v2b(verts), 1, 6 * z) end draw_filled draw_tiled = proc (w: cvt, verts: x_vlist, z: int, tile: x_pixmap, func, planes: int) x_buf$setup(x_drawfilled, func, planes, w) x_buf$set_s01l1(z, 0, p2i(tile)) x_buf$send_data(v2b(verts), 1, 6 * z) end draw_tiled save_region = proc (w: cvt, x, y, width, height: int) returns (x_pixmap) signals (error(string)) x_buf$setup(x_pixmapsave, 0, 0, w) x_buf$set_s0123(height, width, x, y) x_buf$receive() resignal error return(_cvt[int, x_pixmap](x_buf$get_lp0())) end save_region read_xyregion = proc (w: cvt, x, y, width, height: int) returns (_wordvec) signals (error(string)) x_buf$setup(x_pixmapget, XYFormat, 0, w) x_buf$set_s0123(height, width, x, y) x_buf$receive() resignal error b: _bytevec := _bytevec$create(x_buf$get_lp0()) x_buf$receive_data(b) return(b2w(b)) end read_xyregion read_zregion = proc (w: cvt, x, y, width, height: int) returns (_wordvec) signals (error(string)) x_buf$setup(x_pixmapget, ZFormat, 0, w) x_buf$set_s0123(height, width, x, y) x_buf$receive() resignal error b: _bytevec := _bytevec$create(x_buf$get_lp0()) x_buf$receive_data(b) return(b2w(b)) end read_zregion get_id = proc (w: cvt) returns (int) return(w) end get_id equal = proc (w1, w2: cvt) returns (bool) return(w1 = w2) end equal similar = proc (w1, w2: cvt) returns (bool) return(w1 = w2) end similar copy = proc (w: cvt) returns (cvt) return(w) end copy end x_window