Initial version of donated sources by Avertec, 3.4p5.
[tas-yagle.git] / distrib / sources / yagle / xyagle / XTB_pixmap.c
1 /*------------------------------------------------------------\
2 | |
3 | Tool : XYAG |
4 | |
5 | File : Pixmap.c |
6 | |
7 | Authors : Jacomme Ludovic |
8 | Lester Anthony |
9 | |
10 \------------------------------------------------------------*/
11
12 #include <X11/Intrinsic.h>
13 #include <X11/xpm.h>
14 #include <Xm/Xm.h>
15 #include <Xm/Label.h>
16
17 #include MUT_H
18 #include MLO_H
19 #include XTB_H
20 #include XSB_H
21
22 #include "XTB_pixmap.h"
23
24 /*------------------------------------------------------------\
25 | XyagCreatePixmap |
26 \------------------------------------------------------------*/
27
28 Pixmap
29 XyagCreatePixmap(MainWidget, IconBits, IconWidth, IconHeight)
30 Widget MainWidget;
31 char *IconBits;
32 int IconWidth;
33 int IconHeight;
34 {
35 Pixel Foreground;
36 Pixel Background;
37 Pixmap IconPixmap;
38
39 XtVaGetValues(MainWidget,
40 XmNforeground, &Foreground,
41 XmNbackground, &Background,
42 NULL);
43
44 IconPixmap = XCreatePixmapFromBitmapData(XtDisplay(MainWidget),
45 RootWindowOfScreen(XtScreen(MainWidget)),
46 IconBits, IconWidth, IconHeight,
47 Foreground, Background,
48 DefaultDepthOfScreen(XtScreen(MainWidget)));
49
50 return (IconPixmap);
51 }
52
53 /*------------------------------------------------------------\
54 | XyagCreateColorPixmap |
55 \------------------------------------------------------------*/
56
57 Pixmap
58 XyagCreateColorPixmap(MainWidget, IconData)
59 Widget MainWidget;
60 char **IconData;
61 {
62 Display *Dsp;
63 Screen *Scr;
64 int Depth;
65 Pixmap NormalPixmap;
66 XpmAttributes XpmAttr;
67 Pixel Background;
68 XpmColorSymbol XpmTransparentColor[1] = {{NULL, "none", 0}};
69
70 Dsp = XtDisplayOfObject(MainWidget);
71 Scr = XtScreenOfObject(MainWidget);
72 XtVaGetValues(XtIsSubclass(MainWidget, coreWidgetClass) ? MainWidget : XtParent(MainWidget),
73 XmNdepth, &Depth,
74 XmNbackground, &Background,
75 NULL);
76
77 XpmTransparentColor[0].pixel = Background;
78 XpmAttr.valuemask = XpmColorSymbols | XpmCloseness | XpmDepth;
79 XpmAttr.colorsymbols = XpmTransparentColor;
80 XpmAttr.numsymbols = 1;
81 XpmAttr.closeness = 65535;
82 XpmAttr.depth = Depth;
83
84 if ((XpmCreatePixmapFromData(Dsp, RootWindowOfScreen(Scr), IconData, &NormalPixmap, NULL, &XpmAttr)) != XpmSuccess) {
85 return 0;
86 }
87 else return NormalPixmap;
88 }