1 /* $Header: /home/yav/xpx/RCS/icon.c,v 1.7 1996/03/26 15:38:43 yav Exp $
2  * xpx icon
3  * written by yav (UHD98984@pcvan.or.jp)
4  */
5 
6 #include <X11/Xlib.h>
7 #include <X11/Xutil.h>
8 
9 #include "headers.h"
10 #include "xpx.h"
11 #include "work.h"
12 #define PUBLIC_ICON_C
13 #include "extern.h"
14 
15 
16 char rcsid_icon[] = "$Id: icon.c,v 1.7 1996/03/26 15:38:43 yav Exp $";
17 
18 #define BITS static unsigned char
19 #include "iconbits"
20 
21 struct {
22   short w;
23   short h;
24   char *bits;
25 } icondata[] = {
26 #include "iconsize"
27   {0, 0, NULL}
28 };
29 
30 #define IPXMAX	32
31 static Pixmap ipx[IPXMAX];
32 static Pixmap ipx2[IPXMAX];
33 static int ipxn;
34 
icon_pixmap(n)35 Pixmap icon_pixmap(n)
36      int n;
37 {
38   if (n & 0x80)
39     return ipx2[(n&0x7f)-1];
40   return ipx[n-1];
41 }
42 
icon_width(n)43 int icon_width(n)
44      int n;
45 {
46   return icondata[(n & 0x7f)-1].w;
47 }
48 
icon_height(n)49 int icon_height(n)
50      int n;
51 {
52   return icondata[(n & 0x7f)-1].h;
53 }
54 
create_icon_pixmap()55 int create_icon_pixmap()
56 {
57   for (ipxn = 0; ipxn < IPXMAX; ipxn++) {
58     if (icondata[ipxn].bits == NULL)
59       break;
60     ipx[ipxn] =
61       XCreatePixmapFromBitmapData(dsp, DefaultRootWindow(dsp),
62 				  icondata[ipxn].bits,
63 				  icondata[ipxn].w, icondata[ipxn].h,
64 				  fg, bg, DefaultDepth(dsp, scr));
65     if (ipx[ipxn] == None)
66       return error("icon pixmap create error!");
67     ipx2[ipxn] =
68       XCreatePixmapFromBitmapData(dsp, DefaultRootWindow(dsp),
69 				  icondata[ipxn].bits,
70 				  icondata[ipxn].w, icondata[ipxn].h,
71 				  bg, fg, DefaultDepth(dsp, scr));
72     if (ipx2[ipxn] == None)
73       return error("icon pixmap create error!");
74   }
75   return 0;
76 }
77 
free_icon_pixmap()78 void free_icon_pixmap()
79 {
80   int i;
81 
82   for (i = 0; i < ipxn; i++) {
83     XFreePixmap(dsp, ipx[i]);
84     XFreePixmap(dsp, ipx2[i]);
85   }
86 }
87 
88 /* End of file */
89