% Copyright Barbara Liskov 1985 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)) or: oreq, er: ereq := x_buf$get() er.code := x_createwindow + (borderwidth * 2**8) er.ewin := parent er.s0 := height or.s1 := width er.s2 := x or.s3 := y lr(er).l2 := border.id lr(er).l3 := 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)) or: oreq, er: ereq := x_buf$get() er.code := x_createtransparency er.ewin := parent er.s0 := height or.s1 := width er.s2 := x or.s3 := y x_buf$receive() resignal error return(x_buf$get_lp0()) end create_transparency destroy = proc (w: cvt) or: oreq, er: ereq := x_buf$get() er.code := x_destroywindow er.ewin := w end destroy destroy_subwindows = proc (w: cvt) or: oreq, er: ereq := x_buf$get() er.code := x_destroysubwindows er.ewin := w end destroy_subwindows map = proc (w: cvt) or: oreq, er: ereq := x_buf$get() er.code := x_mapwindow er.ewin := w end map map_subwindows = proc (w: cvt) or: oreq, er: ereq := x_buf$get() er.code := x_mapsubwindows er.ewin := w end map_subwindows unmap = proc (w: cvt) or: oreq, er: ereq := x_buf$get() er.code := x_unmapwindow er.ewin := w end unmap unmap_subwindows = proc (w: cvt) or: oreq, er: ereq := x_buf$get() er.code := x_unmapsubwindows er.ewin := w end unmap_subwindows unmap_transparent = proc (w: cvt) or: oreq, er: ereq := x_buf$get() er.code := x_unmaptransparent er.ewin := w end unmap_transparent raise = proc (w: cvt) or: oreq, er: ereq := x_buf$get() er.code := x_raisewindow er.ewin := w end raise lower = proc (w: cvt) or: oreq, er: ereq := x_buf$get() er.code := x_lowerwindow er.ewin := w end lower circulate_up = proc (w: cvt) or: oreq, er: ereq := x_buf$get() er.code := x_circwindowup er.ewin := w end circulate_up circulate_down = proc (w: cvt) or: oreq, er: ereq := x_buf$get() er.code := x_circwindowdown er.ewin := w end circulate_down move = proc (w: cvt, x, y: int) or: oreq, er: ereq := x_buf$get() er.code := x_movewindow er.ewin := w er.s0 := x or.s1 := y end move change = proc (w: cvt, width, height: int) or: oreq, er: ereq := x_buf$get() er.code := x_changewindow er.ewin := w er.s0 := height or.s1 := width end change configure = proc (w: cvt, x, y, width, height: int) or: oreq, er: ereq := x_buf$get() er.code := x_configurewindow er.ewin := w er.s0 := height or.s1 := width er.s2 := x or.s3 := y end configure set_background = proc (w: cvt, background: x_pixmap) or: oreq, er: ereq := x_buf$get() er.code := x_changebackground er.ewin := w lr(er).l0 := p2i(background) end set_background set_border = proc (w: cvt, border: x_pixmap) or: oreq, er: ereq := x_buf$get() er.code := x_changeborder er.ewin := w lr(er).l0 := p2i(border) end set_border set_tilemode = proc (w: cvt, relative: bool) or: oreq, er: ereq := x_buf$get() if relative then er.code := x_tilemode + (TileModeRelative * 2**8) else er.code := x_tilemode + (TileModeAbsolute * 2**8) end er.ewin := w end set_tilemode set_clipmode = proc (w: cvt, drawthru: bool) or: oreq, er: ereq := x_buf$get() if drawthru then er.code := x_clipmode + (ClipModeDrawThru * 2**8) else er.code := x_clipmode + (ClipModeClipped * 2**8) end er.ewin := w 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)) or: oreq, er: ereq := x_buf$get() er.code := x_querywindow er.ewin := 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] or: oreq, er: ereq := x_buf$get() er.code := x_querytree er.ewin := 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)) or: oreq, er: ereq := x_buf$get() er.code := x_fetchname er.ewin := 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) or: oreq, er: ereq := x_buf$get() er.code := x_storename er.ewin := w er.s0 := string$size(n) x_buf$send_data(s2b(n), 1, string$size(n)) end set_name set_icon = proc (w, icon: cvt) or: oreq, er: ereq := x_buf$get() er.code := x_seticonwindow er.ewin := w lr(er).l0 := icon end set_icon get_resize = proc (w: cvt) returns (int, int, int, int) signals (error(string)) or: oreq, er: ereq := x_buf$get() er.code := x_getresizehint er.ewin := 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) or: oreq, er: ereq := x_buf$get() er.code := x_setresizehint er.ewin := w er.s0 := height0 or.s1 := heightinc er.s2 := width0 or.s3 := widthinc end set_resize set_cursor = proc (w: cvt, cursor: x_cursor) or: oreq, er: ereq := x_buf$get() er.code := x_definecursor er.ewin := w lr(er).l0 := c2i(cursor) end set_cursor set_input = proc (w: cvt, mask: int) or: oreq, er: ereq := x_buf$get() er.code := x_selectinput er.ewin := w lr(er).l0 := mask end set_input grab_mouse = proc (w: cvt, mask: int, cursor: x_cursor) signals (error(string)) or: oreq, er: ereq := x_buf$get() er.code := x_grabmouse er.ewin := w lr(er).l0 := c2i(cursor) lr(er).l1 := mask x_buf$receive() resignal error end grab_mouse ungrab_mouse = proc () or: oreq, er: ereq := x_buf$get() er.code := x_ungrabmouse end ungrab_mouse grab_button = proc (w: cvt, button, mask: int, cursor: x_cursor) signals (error(string)) or: oreq, er: ereq := x_buf$get() er.code := x_grabbutton or.mask := button er.ewin := w lr(er).l0 := c2i(cursor) lr(er).l1 := mask x_buf$receive() resignal error end grab_button ungrab_button = proc (button: int) or: oreq, er: ereq := x_buf$get() er.code := x_ungrabmouse or.mask := button end ungrab_button % returns (x, y, window) query_mouse = proc (w: cvt) returns (int, int, cvt) signals (error(string)) or: oreq, er: ereq := x_buf$get() er.code := x_querymouse er.ewin := 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)) or: oreq, er: ereq := x_buf$get() er.code := x_interpretlocator er.ewin := w er.s0 := y or.s1 := x 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) or: oreq, er: ereq := x_buf$get() er.code := x_warpmouse er.ewin := w er.s0 := x or.s1 := y lr(er).l1 := down(x_display$root()) er.s4 := 0 or.s5 := 0 er.s6 := 0 or.s7 := 0 end warp_mouse cond_warp_mouse = proc (dstw: cvt, dstx, dsty: int, srcw: cvt, srcx, srcy, srcwidth, srcheight: int) or: oreq, er: ereq := x_buf$get() er.code := x_warpmouse er.ewin := dstw er.s0 := dstx or.s1 := dsty lr(er).l1 := srcw er.s4 := srcheight or.s5 := srcwidth er.s6 := srcx or.s7 := srcy end cond_warp_mouse focus_keyboard = proc (w: cvt) or: oreq, er: ereq := x_buf$get() er.code := x_focuskeyboard er.ewin := w end focus_keyboard clear = proc (w: cvt) or: oreq, er: ereq := x_buf$get() er.code := x_clear er.ewin := w end clear pix_set = proc (w: cvt, pixel, x, y, width, height: int) or: oreq, er: ereq := x_buf$get() er.code := x_pixfill + (GXcopy * 2**8) or.mask := -1 er.ewin := w er.s0 := height or.s1 := width er.s2 := x or.s3 := y er.s4 := pixel lr(er).l3 := 0 end pix_set pix_fill = proc (w: cvt, pixel: int, mask: x_bitmap, x, y, width, height: int, func, planes: int) or: oreq, er: ereq := x_buf$get() er.code := x_pixfill + (func * 2**8) or.mask := planes er.ewin := w er.s0 := height or.s1 := width er.s2 := x or.s3 := y er.s4 := pixel lr(er).l3 := b2i(mask) end pix_fill tile_set = proc (w: cvt, tile: x_pixmap, x, y, width, height: int) or: oreq, er: ereq := x_buf$get() er.code := x_tilefill + (GXcopy * 2**8) or.mask := -1 er.ewin := w er.s0 := height or.s1 := width er.s2 := x or.s3 := y lr(er).l2 := p2i(tile) lr(er).l3 := 0 end tile_set tile_fill = proc (w: cvt, tile: x_pixmap, mask: x_bitmap, x, y, width, height, func, planes: int) or: oreq, er: ereq := x_buf$get() er.code := x_tilefill + (func * 2**8) or.mask := planes er.ewin := w er.s0 := height or.s1 := width er.s2 := x or.s3 := y lr(er).l2 := p2i(tile) lr(er).l3 := b2i(mask) end tile_fill pixmap_put = proc (w: cvt, pix: x_pixmap, srcx, srcy, width, height, dstx, dsty, func, planes: int) or: oreq, er: ereq := x_buf$get() er.code := x_pixmapput + (func * 2**8) or.mask := planes er.ewin := w er.s0 := height or.s1 := width er.s2 := srcx or.s3 := srcy lr(er).l2 := p2i(pix) er.s6 := dstx or.s7 := dsty end pixmap_put pixmap_zbitsput = proc (w: cvt, width, height: int, bits: _wordvec, mask: x_bitmap, x, y, func, planes: int) or: oreq, er: ereq := x_buf$get() er.code := x_pixmapbitsput + (func * 2**8) or.mask := planes er.ewin := w er.s0 := height or.s1 := width er.s2 := x or.s3 := y er.s4 := ZFormat lr(er).l3 := 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) or: oreq, er: ereq := x_buf$get() er.code := x_pixmapbitsput + (func * 2**8) or.mask := planes er.ewin := w er.s0 := height or.s1 := width er.s2 := x or.s3 := y er.s4 := XYFormat lr(er).l3 := 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) or: oreq, er: ereq := x_buf$get() er.code := x_bitmapbitsput + (func * 2**8) or.mask := planes er.ewin := w er.s0 := height or.s1 := width er.s2 := x or.s3 := y er.s4 := fore or.s5 := back lr(er).l3 := 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) or: oreq, er: ereq := x_buf$get() er.code := x_copyarea + (GXcopy * 2**8) or.mask := -1 er.ewin := w er.s0 := height or.s1 := width er.s2 := srcx or.s3 := srcy er.s6 := dstx or.s7 := dsty end move_area copy_area = proc (w: cvt, srcx, srcy, width, height, dstx, dsty: int, func, planes: int) or: oreq, er: ereq := x_buf$get() er.code := x_copyarea + (func * 2**8) or.mask := planes er.ewin := w er.s0 := height or.s1 := width er.s2 := srcx or.s3 := srcy er.s6 := dstx or.s7 := dsty end copy_area text = proc (w: cvt, s: string, font: x_font, fore, back, x, y: int) or: oreq, er: ereq := x_buf$get() er.code := x_text + (GXcopy * 2**8) or.mask := -1 er.ewin := w er.s0 := x or.s1 := y lr(er).l1 := f2i(font) er.s4 := fore or.s5 := back er.s6 := string$size(s) 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) or: oreq, er: ereq := x_buf$get() er.code := x_text + (GXcopy * 2**8) or.mask := -1 er.ewin := w er.s0 := x or.s1 := y lr(er).l1 := f2i(font) er.s4 := fore or.s5 := back er.s6 := z 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) or: oreq, er: ereq := x_buf$get() er.code := x_text + (GXcopy * 2**8) or.mask := -1 er.ewin := w er.s0 := x or.s1 := y lr(er).l1 := f2i(font) er.s4 := fore or.s5 := back er.s6 := z 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) or: oreq, er: ereq := x_buf$get() er.code := x_text + (func * 2**8) or.mask := planes er.ewin := w er.s0 := x or.s1 := y lr(er).l1 := f2i(font) er.s4 := fore or.s5 := back er.s6 := string$size(s) or.s7 := (cpad // 2**8) + (spad * 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) or: oreq, er: ereq := x_buf$get() er.code := x_text + (func * 2**8) or.mask := planes er.ewin := w er.s0 := x or.s1 := y lr(er).l1 := f2i(font) er.s4 := fore or.s5 := back er.s6 := z or.s7 := (cpad // 2**8) + (spad * 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) or: oreq, er: ereq := x_buf$get() er.code := x_text + (func * 2**8) or.mask := planes er.ewin := w er.s0 := x or.s1 := y lr(er).l1 := f2i(font) er.s4 := fore or.s5 := back er.s6 := z or.s7 := (cpad // 2**8) + (spad * 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) or: oreq, er: ereq := x_buf$get() er.code := x_textmask + (GXcopy * 2**8) or.mask := -1 er.ewin := w er.s0 := x or.s1 := y lr(er).l1 := f2i(font) er.s4 := pixel er.s6 := string$size(s) 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) or: oreq, er: ereq := x_buf$get() er.code := x_textmask + (GXcopy * 2**8) or.mask := -1 er.ewin := w er.s0 := x or.s1 := y lr(er).l1 := f2i(font) er.s4 := pixel er.s6 := z 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) or: oreq, er: ereq := x_buf$get() er.code := x_textmask + (GXcopy * 2**8) or.mask := -1 er.ewin := w er.s0 := x or.s1 := y lr(er).l1 := f2i(font) er.s4 := pixel er.s6 := z 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) or: oreq, er: ereq := x_buf$get() er.code := x_textmask + (func * 2**8) or.mask := planes er.ewin := w er.s0 := x or.s1 := y lr(er).l1 := f2i(font) er.s4 := pixel er.s6 := string$size(s) or.s7 := (cpad // 2**8) + (spad * 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) or: oreq, er: ereq := x_buf$get() er.code := x_textmask + (func * 2**8) or.mask := planes er.ewin := w er.s0 := x or.s1 := y lr(er).l1 := f2i(font) er.s4 := pixel er.s6 := z or.s7 := (cpad // 2**8) + (spad * 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) or: oreq, er: ereq := x_buf$get() er.code := x_textmask + (func * 2**8) or.mask := planes er.ewin := w er.s0 := x or.s1 := y lr(er).l1 := f2i(font) er.s4 := pixel er.s6 := z or.s7 := (cpad // 2**8) + (spad * 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) or: oreq, er: ereq := x_buf$get() er.code := x_line + (func * 2**8) or.mask := planes er.ewin := w er.s0 := x1 or.s1 := y1 er.s2 := x2 or.s3 := y2 er.s4 := pixel or.s5 := (height // 2**8) + (width * 2**8) end line draw = proc (w: cvt, verts: x_vlist, z, pixel, width, height, func, planes: int) or: oreq, er: ereq := x_buf$get() er.code := x_draw + (func * 2**8) or.mask := planes er.ewin := w er.s0 := z or.s1 := pixel er.s2 := (height // 2**8) + (width * 2**8) or.s3 := 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) or: oreq, er: ereq := x_buf$get() er.code := x_draw + (func * 2**8) or.mask := planes er.ewin := w er.s0 := z or.s1 := pixel er.s2 := (height // 2**8) + (width * 2**8) or.s3 := DrawDashedLine or.s5 := pattern er.s6 := patlen or.s7 := 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) or: oreq, er: ereq := x_buf$get() er.code := x_draw + (func * 2**8) or.mask := planes er.ewin := w er.s0 := z or.s1 := pixel er.s2 := (height // 2**8) + (width * 2**8) or.s3 := DrawPatternedLine er.s4 := altpix or.s5 := pattern er.s6 := patlen or.s7 := 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) or: oreq, er: ereq := x_buf$get() er.code := x_drawfilled + (func * 2**8) or.mask := planes er.ewin := w er.s0 := z or.s1 := pixel lr(er).l1 := 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) or: oreq, er: ereq := x_buf$get() er.code := x_drawfilled + (func * 2**8) or.mask := planes er.ewin := w er.s0 := z lr(er).l1 := 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)) or: oreq, er: ereq := x_buf$get() er.code := x_pixmapsave er.ewin := w er.s0 := height or.s1 := width er.s2 := x or.s3 := 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)) or: oreq, er: ereq := x_buf$get() er.code := x_pixmapget + (XYFormat * 2**8) er.ewin := w er.s0 := height or.s1 := width er.s2 := x or.s3 := 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)) or: oreq, er: ereq := x_buf$get() er.code := x_pixmapget + (ZFormat * 2**8) er.ewin := w er.s0 := height or.s1 := width er.s2 := x or.s3 := 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