memdraw, memlalloc, memldelete, memlexpose, memlfree, memlhide,
memline, memlnorefresh, memload, memunload, memlorigin, memlsetrefresh,
memltofront, memltofrontn, memltorear, memltorearn – windows of
#include <u.h> |
typedef struct Memscreen Memscreen;
Memimage* memlalloc(Memscreen *s, Rectangle r, Refreshfn fn, void
*arg, ulong col)
void memlnorefresh(Memimage *i, Rectangle r, void *arg)
int memlsetrefresh(Memimage *i, Refreshfn fn, void *arg)
int memldelete(Memimage *i)
int memlfree(Memimage *i)
int memlexpose(Memimage *i, Rectangle r)
int memlhide(Memimage *i, Rectangle r)
void memltofront(Memimage *i)
void memltofrontn(Memimage**ia, int n)
void memltorear(Memimage *i)
void memltorearn(Memimage **ia , int n)
int memlorigin(Memimage *i, Point log, Point phys)
void memdraw(Image *dst, Rectangle r,
These functions build upon the memdraw(2) interface to maintain
overlapping graphical windows on in–memory images. They are used
by the kernel to implement the windows interface presented by
draw(3) and window(2) and probably have little use outside of
the kernel. |
The basic function is to extend the definition of a Memimage (see memdraw(2)) to include overlapping windows defined by the Memlayer type. The first fields of the Memlayer structure are identical to those in Memimage, permitting a function that expects a Memimage to be passed a Memlayer, and vice versa. Both structures have a save field, which is nil in a Memimage and points to `backing store' in a Memlayer. The layer routines accept Memimages or Memlayers; if the image is a Memimage the underlying Memimage routine is called; otherwise the layer routines recursively subdivide the geometry, reducing the operation into a smaller component that ultimately can be performed on a Memimage, either the display on which the window appears, or the backing store.
Memlayers are associated with a Memscreen that holds the data structures to maintain the windows and connects them to the associated image. The fill color is used to paint the background when a window is deleted. There is no function to establish a Memscreen; to create one, allocate the memory, zero frontmost and rearmost, set fill to a valid fill color or image, and set image to the Memimage (or Memlayer) on which the windows will be displayed.
Memlalloc allocates a Memlayer of size r on Memscreen s. If col is not DNofill, the new window will be initialized by painting it that color.
The refresh function fn and associated argument arg will be called by routines in the library to restore portions of the window uncovered due to another window being deleted or this window being pulled to the front of the stack. The function, when called, receives a pointer to the image (window) being refreshed, the rectangle that has been uncovered, and the arg recorded when the window was created. A couple of predefined functions provide built–in management methods: memlnorefresh does no backup at all, useful for making efficient temporary windows; while a nil function specifies that the backing store (Memlayer.save) will be used to keep the obscured data. Other functions may be provided by the client. Memlsetrefresh allows one to change the function associated with the window.
Memldelete deletes the window i, restoring the underlying display. Memlfree frees the data structures without unlinking the window from the associated Memscreen or doing any graphics.
Memlexpose restores rectangle r within the window, using the backing store or appropriate refresh method. Memlhide goes the other way, backing up r so that that portion of the screen may be modified without losing the data in this window.
Memltofront pulls i to the front of the stack of windows, making it fully visible. Memltofrontn pulls the n windows in the array ia to the front as a group, leaving their internal order unaffected. Memltorear and memltorearn push the windows to the rear.
Memlorigin changes the coordinate systems associated with the window i. The points log and phys represent the upper left corner (min) of the window's internal coordinate system and its physical location on the screen. Changing log changes the interpretation of coordinates within the window; for example, setting it to (0, 0) makes the upper left corner of the window appear to be the origin of the coordinate system, regardless of its position on the screen. Changing phys changes the physical location of the window on the screen. When a window is created, its logical and physical coordinates are the same, so
Memdraw and memline are implemented in the layer library but provide the main entry points for drawing on memory–resident windows. They have the signatures of memimagedraw and memimageline (see memdraw(2)) but accept Memlayer or Memimage arguments both.
Memload and memunload are similarly layer–savvy versions of loadmemimage
and unloadmemimage. The iscompressed flag to memload specifies
whether the n bytes of data in buf are in compressed image format
graphics(2), memdraw(2), stringsize(2), window(2), draw(3)|