12.07.2015 Views

Xlib − C Language X Interface

Xlib − C Language X Interface

Xlib − C Language X Interface

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>Xlib</strong> − C LibraryX11, Release 6.7 DRAFTof the specified drawable, or a BadMatch error results.XCreatePixmapFromBitmapData can generate BadAlloc, BadDrawable, BadGC, and Bad-Value errors.To include a bitmap written out by XWriteBitmapFile in a program directly, asopposed to readingit in every time at run time, use XCreateBitmapFromData.Pixmap XCreateBitmapFromData(display, d, data, width, height)Display *display;Drawable d;char *data;unsigned int width, height;displayddatawidthheightSpecifies the connection to the X server.Specifies the drawable that indicates the screen.Specifies the location of the bitmap data.Specify the width and height.The XCreateBitmapFromData function allows you to include in your C program (using#include) abitmap file that was written out by XWriteBitmapFile (X version 11 format only)without reading in the bitmap file. The following example creates a gray bitmap:#include "gray.bitmap"Pixmap bitmap;bitmap = XCreateBitmapFromData(display, window, gray_bits, gray_width, gray_height);If insufficient working storage was allocated, XCreateBitmapFromData returns None. Itisyour responsibility to free the bitmap using XFreePixmap when finished.XCreateBitmapFromData can generate BadAlloc and BadGC errors.16.10. Using the Context ManagerThe context manager provides a way of associating data with an X resource ID (mostly typicallyawindow) in your program. Note that this is local to your program; the data is not stored in theserver on a property list. Any amount of data in any number of pieces can be associated with aresource ID, and each piece of data has a type associated with it. The context manager requiresknowledge of the resource ID and type to store or retrieve data.Essentially, the context manager can be viewed as a two-dimensional, sparse array: one dimensionis subscripted by the X resource ID and the other by a context type field. Each entry in thearray contains a pointer to the data. <strong>Xlib</strong> provides context management functions with which youcan save data values, get data values, delete entries, and create a unique context type. The symbolsused are in .To save adata value that corresponds to a resource ID and context type, use XSaveContext.422

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!