Skip to content

Graphics Functions

To use the functions defined in this section, you should include the header file <X11/Xmu/Drawing.h> and link against the libXmu library.

void XmuDrawRoundedRectangle(Display *dpy, Drawable draw, GC gc, int x, int y, int w, int h, int ew, int eh);
void XmuDrawRoundedRectangle(Display *dpy, Drawable draw, GC gc, int x, int y, int w, int h, int ew, int eh);

dpy

specifies the connection to the X server

draw

specifies the drawable

gc

specifies the GC

x

specifies the upper left x coordinate

y

specifies the upper left y coordinate

w

specifies the rectangle width

h

specifies the rectangle height

ew

specifies the corner width

eh

specifies the corner height

This function draws a rounded rectangle, where x, y, w, h are the dimensions of the overall rectangle, and ew and eh are the sizes of a bounding box that the corners are drawn inside of; ew should be no more than half of w, and eh should be no more than half of h. The current GC line attributes control all attributes of the line.

void XmuFillRoundedRectangle(Display *dpy, Drawable draw, GC gc, int x, int y, int w, int h, int ew, int eh);
void XmuFillRoundedRectangle(Display *dpy, Drawable draw, GC gc, int x, int y, int w, int h, int ew, int eh);

dpy

specifies the connection to the X server

draw

specifies the drawable

gc

specifies the GC

x

specifies the upper left x coordinate

y

specifies the upper left y coordinate

w

specifies the rectangle width

h

specifies the rectangle height

ew

specifies the corner width

eh

specifies the corner height

This function draws a filled rounded rectangle, where x, y, w, h are the dimensions of the overall rectangle, and ew and eh are the sizes of a bounding box that the corners are drawn inside of; ew should be no more than half of w, and eh should be no more than half of h. The current GC fill settings control all attributes of the fill contents.

XmuDrawLogo(Display *dpy, Drawable drawable, GC gcFore, GC gcBack, int x, int y, unsigned int width, unsigned int height);
XmuDrawLogo(Display *dpy, Drawable drawable, GC gcFore, GC gcBack, int x, int y, unsigned int width, unsigned int height);

dpy

specifies the connection to the X server

drawable

specifies the drawable

gcFore

specifies the foreground GC

gcBack

specifies the background GC

x

specifies the upper left x coordinate

y

specifies the upper left y coordinate

width

specifies the logo width

height

specifies the logo height

This function draws the “official” X Window System logo (Figure 1, “The X Logo”). The bounding box of the logo in the drawable is given by x, y, width, and height. The logo itself is filled using gcFore, and the rest of the rectangle is filled using gcBack.


Pixmap XmuCreateStippledPixmap(Screen *screen, Pixel fore, Pixel back, unsigned int depth);
Pixmap XmuCreateStippledPixmap(Screen *screen, Pixel fore, Pixel back, unsigned int depth);

screen

specifies the screen the pixmap is created on

fore

specifies the foreground pixel value

back

specifies the background pixel value

depth

specifies the depth of the pixmap

This function creates a two pixel by one pixel stippled pixmap of specified depth on the specified screen. The pixmap is cached so that multiple requests share the same pixmap. The pixmap should be freed with XmuReleaseStippledPixmap to maintain correct reference counts.

void XmuReleaseStippledPixmap(Screen *screen, Pixmap pixmap);
void XmuReleaseStippledPixmap(Screen *screen, Pixmap pixmap);

screen

specifies the screen the pixmap was created on

pixmap

specifies the pixmap to free

This function frees a pixmap created with XmuCreateStippledPixmap.

int XmuReadBitmapData(FILE *fstream, unsigned int *width, unsigned int *height, unsigned char **datap, int *x_hot, int *y_hot);
int XmuReadBitmapData(FILE *fstream, unsigned int *width, unsigned int *height, unsigned char **datap, int *x_hot, int *y_hot);

fstream

specifies the stream to read from

width

returns the width of the bitmap

height

returns the height of the bitmap

datap

returns the parsed bitmap data

x_hot

returns the x coordinate of the hotspot

y_hot

returns the y coordinate of the hotspot

This function reads a standard bitmap file description from the specified stream, and returns the parsed data in a format suitable for passing to XCreateBitmapFromData. The return value of the function has the same interpretation as the return value for XReadBitmapFile.

int XmuReadBitmapDataFromFile(const char *filename, unsigned int *width, unsigned int *height, unsigned char **datap, int *x_hot, int *y_hot);
int XmuReadBitmapDataFromFile(const char *filename, unsigned int *width, unsigned int *height, unsigned char **datap, int *x_hot, int *y_hot);

fstream

specifies the file to read from

width

returns the width of the bitmap

height

returns the height of the bitmap

datap

returns the parsed bitmap data

x_hot

returns the x coordinate of the hotspot

y_hot

returns the y coordinate of the hotspot

This function reads a standard bitmap file description from the specified file, and returns the parsed data in a format suitable for passing to XCreateBitmapFromData. The return value of the function has the same interpretation as the return value for XReadBitmapFile.

Pixmap XmuLocateBitmapFile(Screen *screen, const char *name, char *srcname, int srcnamelen, int *widthp, int *heightp, int *xhotp, int *yhotp);
Pixmap XmuLocateBitmapFile(Screen *screen, const char *name, char *srcname, int srcnamelen, int *widthp, int *heightp, int *xhotp, int *yhotp);

screen

specifies the screen the pixmap is created on

name

specifies the file to read from

srcname

returns the full filename of the bitmap

srcnamelen

specifies the length of the srcname buffer

width

returns the width of the bitmap

height

returns the height of the bitmap

xhotp

returns the x coordinate of the hotspot

yhotp

returns the y coordinate of the hotspot

This function reads a file in standard bitmap file format, using XReadBitmapFile, and returns the created bitmap. The filename may be absolute, or relative to the global resource named bitmapFilePath with class BitmapFilePath. If the resource is not defined, the default value is the build symbol BITMAPDIR, which is typically "/usr/include/X11/bitmaps". If srcnamelen is greater than zero and srcname is not NULL, the null terminated filename will be copied into srcname. The size and hotspot of the bitmap are also returned.

Pixmap XmuCreatePixmapFromBitmap(Display *dpy, Drawable d, Pixmap bitmap, unsigned int width, unsigned int height, unsigned int depth, unsigned long fore, unsigned long back);
Pixmap XmuCreatePixmapFromBitmap(Display *dpy, Drawable d, Pixmap bitmap, unsigned int width, unsigned int height, unsigned int depth, unsigned long fore, unsigned long back);

dpy

specifies the connection to the X server

screen

specifies the screen the pixmap is created on

bitmap

specifies the bitmap source

width

specifies the width of the pixmap

height

specifies the height of the pixmap

depth

specifies the depth of the pixmap

fore

specifies the foreground pixel value

back

specifies the background pixel value

This function creates a pixmap of the specified width, height, and depth, on the same screen as the specified drawable, and then performs an XCopyPlane from the specified bitmap to the pixmap, using the specified foreground and background pixel values. The created pixmap is returned.