File: Picture.cc

package info (click to toggle)
xbill 2.0-9
  • links: PTS
  • area: main
  • in suites: slink
  • size: 528 kB
  • ctags: 339
  • sloc: cpp: 1,803; makefile: 38; sh: 21
file content (33 lines) | stat: -rw-r--r-- 949 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include "Picture.h"
#include "objects.h"

void Picture::load(const char *name, int index) {
	static char *dir = strdup(
		access(XBILL_HOME "pixmaps/logo.xpm", R_OK) ? "" : XBILL_HOME);
	int i;
	char file[255];
	Pixmap mask;
	XpmAttributes attr;
	unsigned long gcmask;
	XGCValues gcval;
	gcmask = GCForeground|GCBackground|GCGraphicsExposures;
	gcval.graphics_exposures = False;
	attr.valuemask= XpmCloseness | XpmReturnPixels | XpmColormap | XpmDepth;
	attr.closeness = 65535;
	attr.colormap = ui.colormap;
	attr.depth = ui.depth;
	if (index>=0)
		sprintf (file, "%spixmaps/%s_%d.xpm", dir, name, index);
	else sprintf
		(file, "%spixmaps/%s.xpm", dir, name);
	i = XpmReadFileToPixmap(ui.display, ui.rootwindow, file, &pix,
		&mask, &attr);
	if (i<0) {
		printf ("cannot open %s\n", file);
		exit(1);
	}
	gc = XCreateGC (ui.display, ui.offscreen, gcmask, &gcval);
	XSetClipMask(ui.display, gc, mask);
	width = attr.width;
	height = attr.height;
}